From b46a96d45458f3374d51c7376bae631912563cbb Mon Sep 17 00:00:00 2001 From: Michael Grant Date: Thu, 29 Jan 2026 14:34:18 +0000 Subject: [PATCH] Second try with static visual_ranges using calloc. --- screen-redraw.c | 8 ++++++-- screen-write.c | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/screen-redraw.c b/screen-redraw.c index 25857be8..5350e64a 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -1137,8 +1137,7 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px, struct window_pane *wp; struct window *w; struct visible_range *ri; - static struct visible_range sr0 = { 0, 0 }; - static struct visible_ranges sr = { &sr0, 1, 1 }; + static struct visible_ranges sr = { NULL, 0, 0 }; int found_self, sb_w, sb_pos; u_int lb, rb, tb, bb; u_int i, s; @@ -1148,8 +1147,13 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px, return (r); } else { /* Return static range as last resort. */ + if (sr.ranges == NULL) + sr.ranges = xcalloc(1, + sizeof (struct visible_range)); sr.ranges[0].px = px; sr.ranges[0].nx = width; + sr.size = 1; + sr.used = 1; return (&sr); } } diff --git a/screen-write.c b/screen-write.c index d7362da0..df176083 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1849,13 +1849,13 @@ screen_write_collect_flush(struct screen_write_ctx *ctx, int scroll_only, ctx->scrolled = s->rlower - s->rupper + 1; screen_write_initctx(ctx, &ttyctx, 1); - if (wp->yoff + wp->sy > wp->window->sy) + if (wp != NULL && wp->yoff + wp->sy > wp->window->sy) ttyctx.orlower -= (wp->yoff + wp->sy - wp->window->sy); ttyctx.num = ctx->scrolled; ttyctx.bg = ctx->bg; tty_write(tty_cmd_scrollup, &ttyctx); - if (ctx->wp != NULL) + if (wp != NULL) ctx->wp->flags |= PANE_REDRAWSCROLLBAR; } ctx->scrolled = 0;