Skip to content

Commit dece32b

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 790603a commit dece32b

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
@@ -1122,7 +1122,7 @@ static enum get_oid_result get_parent(struct repository *r,
11221122
if (ret)
11231123
return ret;
11241124
commit = lookup_commit_reference(r, &oid);
1125-
if (repo_parse_commit(r, commit))
1125+
if (!commit || repo_parse_commit(r, commit))
11261126
return MISSING_OBJECT;
11271127
if (!idx) {
11281128
oidcpy(result, &commit->object.oid);

0 commit comments

Comments
 (0)