From: Johannes Schindelin via GitGitGadget Date: Thu, 15 May 2025 12:45:35 GMT Subject: [PATCH 10/14] describe: defensive programming Message-ID: <10393c2f951e30e6b8529ff4fafb4394c3840485.1747313140.git.gitgitgadget@gmail.com> In-Reply-To: From: Johannes Schindelin CodeQL points out that `lookup_commit_reference()` can return NULL values. Signed-off-by: Johannes Schindelin --- builtin/describe.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin/describe.c b/builtin/describe.c index e2e73f3d757c..455ca193ebd3 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -324,6 +324,8 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst) unsigned int unannotated_cnt = 0; cmit = lookup_commit_reference(the_repository, oid); + if (!cmit) + die(_("could not look up commit '%s'"), oid_to_hex(oid)); n = find_commit_name(&cmit->object.oid); if (n && (tags || all || n->prio == 2)) { -- gitgitgadget