]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-patch.c
Fix segfault in patch view for root commit
[ps-cgit] / ui-patch.c
index e7a010accb58f0489f839a19fd3007733199c6ac..7ee2c416ee3825630b0c7014b12a99020555a0b5 100644 (file)
@@ -88,7 +88,11 @@ void cgit_print_patch(char *hex, struct cacheitem *item)
                return;
        }
        info = cgit_parse_commit(commit);
-       hashcpy(old_sha1, commit->parents->item->object.sha1);
+
+       if (commit->parents && commit->parents->item)
+               hashcpy(old_sha1, commit->parents->item->object.sha1);
+       else
+               hashclr(old_sha1);
 
        patchname = fmt("%s.patch", sha1_to_hex(sha1));
        cgit_print_snapshot_start("text/plain", patchname, item);