The delta8_* helpers consume whole blocks per iteration (16 pixels for
the gray8 unrolled/SSE2/NEON variants, 4 pixels for the rgb32 ones). The
SSE2 and NEON variants require the pixel count to be an exact multiple of
that block: a shorter count wraps the loop counter past zero and runs off
the end of memory, and the unrolled C variants overrun by up to a block.
Since PR #4788 made Delta stride-aware it drives those helpers row by row
with the row width as the count. update_function_pointers() only falls
back to the scalar helpers when total pixels % 4 is non-zero, which does
not imply each row width is block-aligned. A monitor whose width is not a
multiple of 16 (e.g. 1366) therefore reaches sse2_delta8_gray8 with a
count of 1366 and zmc dies with SIGSEGV in that loop.
Run the block-aligned bulk of each row through the fast/SIMD helper and
finish the remaining tail pixels with the matching one-pixel-at-a-time
scalar helper.
tests/zm_image_delta.cpp exercises gray8 (widths 17 and 1366) and rgb32
(width 6) at counts that select the SIMD path; each reproduces the crash
on the unfixed code and verifies the per-pixel result on the fix.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>