[PATCH 01/14] revision: defensive programming
- From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
- Date
- May 15, 2025, 12:45 UTC
- Message-ID
- <604e67ee64167efd5282b9efabbcb6e72eeaf5e6.1747313140.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1890.git.1747313139.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
On the off chance that `lookup_decoration()` cannot find anything, let `leave_one_treesame_to_parent()` return gracefully instead of crashing.
Pointed out by CodeQL.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- revision.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/revision.c b/revision.c index c4390f0938cb..59eae4eb8ba8 100644 --- a/revision.c +++ b/revision.c @@ -3359,6 +3359,9 @@ static int leave_one_treesame_to_parent(struct rev_info *revs, struct commit *co struct commit_list *p; unsigned n; + if (!ts) + return 0; + for (p = commit->parents, n = 0; p; p = p->next, n++) { if (ts->treesame[n]) { if (p->item->object.flags & TMP_MARK) {
-- gitgitgadget