Skip to content

Commit 27c5fa3

Browse files
dschogitster
authored andcommitted
verify_commit_graph(): 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 886dbcf commit 27c5fa3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

commit-graph.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,6 +2788,11 @@ static int verify_one_commit_graph(struct repository *r,
27882788
the_repository->hash_algo);
27892789

27902790
graph_commit = lookup_commit(r, &cur_oid);
2791+
if (!graph_commit) {
2792+
graph_report(_("failed to look up commit %s for commit-graph"),
2793+
oid_to_hex(&cur_oid));
2794+
continue;
2795+
}
27912796
odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
27922797
if (repo_parse_commit_internal(r, odb_commit, 0, 0)) {
27932798
graph_report(_("failed to parse commit %s from object database for commit-graph"),

0 commit comments

Comments
 (0)