Re: [PATCH 1/1] diffcore-break: prevent dangling pointer
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 11, 2026, 17:54 UTC
- Message-ID
- <xmqqfr77upxj.fsf@gitster.g>
- In-Reply-To
- <20260211041128.48412-2-hanyang.tony@bytedance.com>
Han Young <hanyang.tony@bytedance.com> writes:
Show 5 quoted lines
> After we have freed the file pair, we should set the queue reference to null. > This prevents us from encountering a dangling pointer later on. > --- > diffcore-break.c | 1 + > 1 file changed, 1 insertion(+)
Missing are sign-off and tests.
This reminds me of 56d388e6 (diff: avoid segfault with freed entries, 2025-12-29).
Show 13 quoted lines
> > diff --git a/diffcore-break.c b/diffcore-break.c > index c4c2173f30..9b11fe2fa0 100644 > --- a/diffcore-break.c > +++ b/diffcore-break.c > @@ -222,6 +222,7 @@ void diffcore_break(struct repository *r, int break_score) > free(p); /* not diff_free_filepair(), we are > * reusing one and two here. > */ > + q->queue[i] = NULL; > continue; > } > }