From d22ab85b84fbeaacc933e393e7225f4e7927000a Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 23 Mar 2026 08:45:30 +0000 Subject: [PATCH] Protect against overflow when scrollbar is off screen, from san65384 at gmail dot com in GitHub issue 4933. --- screen-redraw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/screen-redraw.c b/screen-redraw.c index 138edd52..88653f34 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -1091,12 +1091,13 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx, sy += ctx->statuslines; } - /* Set up style for slider. */ gc = sb_style->gc; memcpy(&slgc, &gc, sizeof slgc); slgc.fg = gc.bg; slgc.bg = gc.fg; + if (sb_x >= sx || sb_y >= sy) + return; imax = sb_w + sb_pad; if ((int)imax + sb_x > sx) imax = sx - sb_x;