commit afc3008b718fd295a4ce073d3143bd2c4032cea8
parent bc0b2b45f9526f6c585958e4746589ebe2a0b7dd
Author: Chris Bracken <chris@bracken.jp>
Date: Wed, 18 Feb 2026 17:13:43 +0900
writers: safer dereference of parentoid
Diffstat:
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/writer/gopher/commit.c b/src/writer/gopher/commit.c
@@ -98,7 +98,7 @@ void gopher_commit_write_summary(GopherCommit* commit,
fprintf(out, "[1|commit %s|../commit/%s.gph|server|port]\n", oid, oid);
const char* parentoid = git_commit->parentoid;
- if (parentoid[0] != '\0') {
+ if (parentoid && parentoid[0] != '\0') {
fprintf(out, "[1|parent %s|../commit/%s.gph|server|port]\n", parentoid,
parentoid);
}
diff --git a/src/writer/html/commit.c b/src/writer/html/commit.c
@@ -101,7 +101,7 @@ void html_commit_write_summary(HtmlCommit* commit,
fprintf(out, "<a href=\"../commit/%s.html\">%s</a>\n", oid, oid);
const char* parentoid = git_commit->parentoid;
- if (parentoid[0] != '\0') {
+ if (parentoid && parentoid[0] != '\0') {
fprintf(out, "<b>parent</b> ");
fprintf(out, "<a href=\"../commit/%s.html\">%s</a>\n", parentoid,
parentoid);