Skip to content

Commit f44f334

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

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
@@ -1108,7 +1108,7 @@ static enum get_oid_result get_parent(struct repository *r,
11081108
if (ret)
11091109
return ret;
11101110
commit = lookup_commit_reference(r, &oid);
1111-
if (repo_parse_commit(r, commit))
1111+
if (!commit || repo_parse_commit(r, commit))
11121112
return MISSING_OBJECT;
11131113
if (!idx) {
11141114
oidcpy(result, &commit->object.oid);

0 commit comments

Comments
 (0)