commit 579bd556f987d6059cca7f20219140dae23079f3 from: Stefan Sperling date: Sat Oct 24 13:18:03 2020 UTC prevent a NULL dereference if 'got log -p' runs against a root commit commit - eef9542c44a360aeec73151d75342f0559a590b4 commit + 579bd556f987d6059cca7f20219140dae23079f3 blob - 5bfcaac31178afc5018d764b995989379c1ccfe7 blob + 40ab964e77891970bf5fa1e069607c1aa4a6c250 --- got/got.c +++ got/got.c @@ -3297,10 +3297,12 @@ print_patch(struct got_commit_object *commit, struct g err = got_object_id_str(&id_str2, obj_id2); if (err) goto done; - obj_id1 = got_object_commit_get_tree_id(pcommit); - err = got_object_id_str(&id_str1, obj_id1); - if (err) - goto done; + if (pcommit) { + obj_id1 = got_object_commit_get_tree_id(pcommit); + err = got_object_id_str(&id_str1, obj_id1); + if (err) + goto done; + } printf("diff %s %s\n", id_str1 ? id_str1 : "/dev/null", id_str2); err = diff_trees(obj_id1, obj_id2, "", diff_context, 0, repo); }