Re: [PATCH 02/14] get_parent(): defensive programming
- From
Jeff King <peff@peff.net>
- Date
- May 15, 2025, 20:32 UTC
- Message-ID
- <20250515203223.GN3320240@coredump.intra.peff.net>
- In-Reply-To
- <35c4870e2c101c9ef72d1657c8f6dd077cecc5fa.1747313140.git.gitgitgadget@gmail.com>
On Thu, May 15, 2025 at 12:45:27PM +0000, Johannes Schindelin via GitGitGadget wrote:
Show 7 quoted lines
> CodeQL points out that `lookup_commit_reference()` can return NULL > values. > [...] > commit = lookup_commit_reference(r, &oid); > - if (repo_parse_commit(r, commit)) > + if (!commit || repo_parse_commit(r, commit)) > return MISSING_OBJECT;
Sure, but repo_parse_commit() can also handle NULL values. It returns "-1" in that case. I think CodeQL is not smart enough to know that.
-Peff