Skip to content

Commit 0691fe8

Browse files
committed
verify_commit_graph(): defensive programming
CodeQL points out that `lookup_commit()` can return NULL values. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent fd9d010 commit 0691fe8

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
@@ -2783,6 +2783,11 @@ static int verify_one_commit_graph(struct commit_graph *g,
27832783
g->hash_algo);
27842784

27852785
graph_commit = lookup_commit(r, &cur_oid);
2786+
if (!graph_commit) {
2787+
graph_report(_("failed to look up commit %s for commit-graph"),
2788+
oid_to_hex(&cur_oid));
2789+
continue;
2790+
}
27862791
odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
27872792
if (repo_parse_commit_internal(r, odb_commit, 0, 0)) {
27882793
graph_report(_("failed to parse commit %s from object database for commit-graph"),

0 commit comments

Comments
 (0)