Skip to content

Commit b5bb46b

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

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
@@ -2797,6 +2797,11 @@ static int verify_one_commit_graph(struct repository *r,
27972797
the_repository->hash_algo);
27982798

27992799
graph_commit = lookup_commit(r, &cur_oid);
2800+
if (!graph_commit) {
2801+
graph_report(_("failed to look up commit %s for commit-graph"),
2802+
oid_to_hex(&cur_oid));
2803+
continue;
2804+
}
28002805
odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
28012806
if (repo_parse_commit_internal(r, odb_commit, 0, 0)) {
28022807
graph_report(_("failed to parse commit %s from object database for commit-graph"),

0 commit comments

Comments
 (0)