[PATCH 14/14] shallow: handle missing shallow commits gracefully
From: Johannes Schindelin <johannes.schindelin@gmx.de>
As pointed out by CodeQL, `lookup_commit()` can return NULL.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
shallow.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/shallow.c b/shallow.c
index 4bd9342c9a74..011f262cc7d4 100644
--- a/shallow.c
+++ b/shallow.c
@@ -702,7 +702,8 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
for (i = 0; i < nr_shallow; i++) {
struct commit *c = lookup_commit(the_repository,
&oid[shallow[i]]);
- c->object.flags |= BOTTOM;
+ if (c)
+ c->object.flags |= BOTTOM;
}
for (i = 0; i < ref->nr; i++)
--
gitgitgadget