Subject: [PATCH 14/14] shallow: handle missing shallow commits gracefully

From: "Johannes Schindelin via GitGitGadget" <[email-masked]>
Date: Thu, 15 May 2025 12:45:39 +0000

From: Johannes Schindelin <[email-masked]>

As pointed out by CodeQL, `lookup_commit()` can return NULL.

Signed-off-by: Johannes Schindelin <[email-masked]>
---
 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