gout

A static git page generator
git clone https://git.bracken.jp/gout.git
Log | Files | Refs | README | LICENSE

commit b8674a432d3ab9f65caec13826c7e74269cc80bd
parent afc3008b718fd295a4ce073d3143bd2c4032cea8
Author: Chris Bracken <chris@bracken.jp>
Date:   Fri, 20 Feb 2026 12:38:35 +0900

writer: safer string dereferences

Diffstat:
Msrc/writer/gopher/page.c | 12++++++------
Msrc/writer/html/page.c | 12++++++------
2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/writer/gopher/page.c b/src/writer/gopher/page.c @@ -40,18 +40,18 @@ void gopher_page_begin(GopherPage* page) { FILE* out = page->out; print_gopher_text(out, page->title, false); const char* short_name = gitrepo_short_name(page->repo); - if (page->title[0] != '\0' && short_name[0] != '\0') { + if (page->title[0] != '\0' && short_name && short_name[0] != '\0') { fprintf(out, " - "); print_gopher_text(out, short_name, false); } const char* description = gitrepo_description(page->repo); - if (page->title[0] != '\0' && description[0] != '\0') { + if (page->title[0] != '\0' && description && description[0] != '\0') { fprintf(out, " - "); print_gopher_text(out, description, false); fprintf(out, "\n"); } const char* clone_url = gitrepo_clone_url(page->repo); - if (clone_url[0] != '\0') { + if (clone_url && clone_url[0] != '\0') { fprintf(out, "[h|git clone "); print_gopher_link(out, clone_url); fprintf(out, "|URL:"); @@ -63,17 +63,17 @@ void gopher_page_begin(GopherPage* page) { fprintf(out, "[1|Refs|%srefs.gph|server|port]\n", page->relpath); const char* submodules = gitrepo_submodules(page->repo); - if (submodules[0] != '\0') { + if (submodules && submodules[0] != '\0') { fprintf(out, "[1|Submodules|%sfile/%s.gph|server|port]\n", page->relpath, submodules); } const char* readme = gitrepo_readme(page->repo); - if (readme[0] != '\0') { + if (readme && readme[0] != '\0') { fprintf(out, "[1|README|%sfile/%s.gph|server|port]\n", page->relpath, readme); } const char* license = gitrepo_license(page->repo); - if (license[0] != '\0') { + if (license && license[0] != '\0') { fprintf(out, "[1|LICENSE|%sfile/%s.gph|server|port]\n", page->relpath, license); } diff --git a/src/writer/html/page.c b/src/writer/html/page.c @@ -50,12 +50,12 @@ void html_page_begin(HtmlPage* page) { print_xml_encoded(out, page->title); const char* short_name = gitrepo_short_name(page->repo); - if (page->title[0] != '\0' && short_name[0] != '\0') { + if (page->title[0] != '\0' && short_name && short_name[0] != '\0') { fprintf(out, " - "); print_xml_encoded(out, short_name); } const char* description = gitrepo_description(page->repo); - if (page->title[0] != '\0' && description[0] != '\0') { + if (page->title[0] != '\0' && description && description[0] != '\0') { fprintf(out, " - "); print_xml_encoded(out, description); } @@ -87,7 +87,7 @@ void html_page_begin(HtmlPage* page) { fprintf(out, "</span></td></tr>"); const char* clone_url = gitrepo_clone_url(page->repo); - if (clone_url[0] != '\0') { + if (clone_url && clone_url[0] != '\0') { fprintf(out, "<tr class=\"url\"><td></td><td>git clone "); if (is_safe_url(clone_url)) { fprintf(out, "<a href=\""); @@ -106,19 +106,19 @@ void html_page_begin(HtmlPage* page) { fprintf(out, "<a href=\"%srefs.html\">Refs</a>", relpath); const char* submodules = gitrepo_submodules(page->repo); - if (submodules[0] != '\0') { + if (submodules && submodules[0] != '\0') { fprintf(out, " | <a href=\"%sfile/", relpath); print_xml_encoded(out, submodules); fprintf(out, ".html\">Submodules</a>"); } const char* readme = gitrepo_readme(page->repo); - if (readme[0] != '\0') { + if (readme && readme[0] != '\0') { fprintf(out, " | <a href=\"%sfile/", relpath); print_xml_encoded(out, readme); fprintf(out, ".html\">README</a>"); } const char* license = gitrepo_license(page->repo); - if (license[0] != '\0') { + if (license && license[0] != '\0') { fprintf(out, " | <a href=\"%sfile/", relpath); print_xml_encoded(out, license); fprintf(out, ".html\">LICENSE</a>");