]> git.99rst.org Git - git.git/commit
diffcore-break: guard against NULLed queue entries in merge loop
authorJohannes Schindelin <redacted>
Fri, 10 Jul 2026 11:39:25 +0000 (11:39 +0000)
committerJunio C Hamano <redacted>
Fri, 10 Jul 2026 15:13:54 +0000 (08:13 -0700)
commita6b8f0143101f35bd5cc59ec5d51c9c4d428620c
tree2222752f5826237c096901cd2b8fa787c4d8a582
parentf85a7e662054a7b0d9070e432508831afa214b47
diffcore-break: guard against NULLed queue entries in merge loop

The outer loop in `diffcore_merge_broken()` sets `q->queue[j]` to NULL
when it merges a broken pair back together, and has a NULL check to skip
such entries on subsequent iterations. The inner loop, however, lacks
this guard: when it scans forward looking for a matching peer, it can
encounter a slot that was NULLed by a previous outer-loop iteration and
dereference it unconditionally.

In practice this requires at least two broken pairs whose peers
both survive rename/copy detection and appear later in the queue,
which is rare but not impossible.

Add the same `if (!pp) continue` guard to the inner loop.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
diffcore-break.c
git clone https://git.99rst.org/PROJECT