Skip to content

Commit 886dbcf

Browse files
dschogitster
authored andcommitted
unparse_commit(): defensive programming
CodeQL points out that `lookup_commit()` can return NULL values. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent add8982 commit 886dbcf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void unparse_commit(struct repository *r, const struct object_id *oid)
188188
{
189189
struct commit *c = lookup_commit(r, oid);
190190

191-
if (!c->object.parsed)
191+
if (!c || !c->object.parsed)
192192
return;
193193
free_commit_list(c->parents);
194194
c->parents = NULL;

0 commit comments

Comments
 (0)