Skip to content

Commit 765a31d

Browse files
committed
unparse_commit(): defensive programming
CodeQL points out that `lookup_commit()` can return NULL values. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 4cb0912 commit 765a31d

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
@@ -189,7 +189,7 @@ void unparse_commit(struct repository *r, const struct object_id *oid)
189189
{
190190
struct commit *c = lookup_commit(r, oid);
191191

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

0 commit comments

Comments
 (0)