Skip to content

Commit 017717c

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 05a18da commit 017717c

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

27752775
graph_commit = lookup_commit(r, &cur_oid);
2776+
if (!graph_commit) {
2777+
graph_report(_("failed to look up commit %s for commit-graph"),
2778+
oid_to_hex(&cur_oid));
2779+
continue;
2780+
}
27762781
odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
27772782
if (repo_parse_commit_internal(r, odb_commit, 0, 0)) {
27782783
graph_report(_("failed to parse commit %s from object database for commit-graph"),

0 commit comments

Comments
 (0)