Skip to content

Commit 1f4d572

Browse files
committed
shallow: handle missing shallow commits gracefully
As pointed out by CodeQL, `lookup_commit()` can return NULL. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 5234177 commit 1f4d572

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎shallow.c‎

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

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

0 commit comments

Comments
 (0)