Skip to content

Commit ffde052

Browse files
dschogitster
authored andcommitted
shallow: handle missing shallow commits gracefully
As pointed out by CodeQL, `lookup_commit()` can return NULL. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3fef606 commit ffde052

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
@@ -705,7 +705,8 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
705705
for (i = 0; i < nr_shallow; i++) {
706706
struct commit *c = lookup_commit(the_repository,
707707
&oid[shallow[i]]);
708-
c->object.flags |= BOTTOM;
708+
if (c)
709+
c->object.flags |= BOTTOM;
709710
}
710711

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

0 commit comments

Comments
 (0)