Fix infinite loop due to underflow when redrawing scrollbar, from Pavel

Lavrukhin in GitHub issue 4932.
This commit is contained in:
nicm
2026-05-12 09:32:49 +00:00
parent 800837ff3f
commit 27a00d1bfd

View File

@@ -1108,11 +1108,17 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx,
if (sb_x >= sx || sb_y >= sy) if (sb_x >= sx || sb_y >= sy)
return; return;
imax = sb_w + sb_pad; imax = sb_w + sb_pad;
if ((int)imax + sb_x > sx) if ((int)imax + sb_x > sx) {
if (sb_x >= sx)
return;
imax = sx - sb_x; imax = sx - sb_x;
}
jmax = sb_h; jmax = sb_h;
if ((int)jmax + sb_y > sy) if ((int)jmax + sb_y > sy) {
if (sb_y >= sy)
return;
jmax = sy - sb_y; jmax = sy - sb_y;
}
for (j = 0; j < jmax; j++) { for (j = 0; j < jmax; j++) {
py = sb_y + j; py = sb_y + j;