Skip to content

Commit 07ea788

Browse files
committed
get_parent(): defensive programming
CodeQL points out that `lookup_commit_reference()` can return NULL values. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 877e3a3 commit 07ea788

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

object-name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ static enum get_oid_result get_parent(struct repository *r,
11211121
if (ret)
11221122
return ret;
11231123
commit = lookup_commit_reference(r, &oid);
1124-
if (repo_parse_commit(r, commit))
1124+
if (!commit || repo_parse_commit(r, commit))
11251125
return MISSING_OBJECT;
11261126
if (!idx) {
11271127
oidcpy(result, &commit->object.oid);

0 commit comments

Comments
 (0)