Skip to content

Commit 17e9e9a

Browse files
committed
shallow: handle missing shallow commits gracefully
As pointed out by CodeQL, `lookup_commit()` can return NULL. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 137f6c4 commit 17e9e9a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

shallow.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,8 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
702702
for (i = 0; i < nr_shallow; i++) {
703703
struct commit *c = lookup_commit(the_repository,
704704
&oid[shallow[i]]);
705-
c->object.flags |= BOTTOM;
705+
if (c)
706+
c->object.flags |= BOTTOM;
706707
}
707708

708709
for (i = 0; i < ref->nr; i++)

0 commit comments

Comments
 (0)