[PATCH 10/14] describe: defensive programming
- From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
- Date
- May 15, 2025, 12:45 UTC
- Message-ID
- <10393c2f951e30e6b8529ff4fafb4394c3840485.1747313140.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1890.git.1747313139.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
CodeQL points out that `lookup_commit_reference()` can return NULL values.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- 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