From 919e06c8438bbbc9b214f2caacfe14ea031844e3 Mon Sep 17 00:00:00 2001 From: CismonX Date: Fri, 31 Jul 2026 12:49:51 +0800 Subject: selection: check column when updating selection Selection coordinates may appear outside of the terminal grid (e.g., during the "fast resize" stage of delayed resize), resulting in bad width passed to pixman_region32_union_rect(). --- selection.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/selection.c b/selection.c index 818a6834..554d61b4 100644 --- a/selection.c +++ b/selection.c @@ -795,10 +795,12 @@ pixman_region_for_coords_normal(const struct terminal *term, if (rel_start_row < rel_end_row) { /* First partial row (start ->)*/ - pixman_region32_union_rect( - ®ion, ®ion, - start->col, rel_start_row, - term->cols - start->col, 1); + if (term->cols > start->col) { + pixman_region32_union_rect( + ®ion, ®ion, + start->col, rel_start_row, + term->cols - start->col, 1); + } /* Full rows between start and end */ if (rel_start_row + 1 < rel_end_row) { @@ -816,10 +818,12 @@ pixman_region_for_coords_normal(const struct terminal *term, } else if (rel_start_row > rel_end_row) { /* First partial row (end ->) */ - pixman_region32_union_rect( - ®ion, ®ion, - end->col, rel_end_row, - term->cols - end->col, 1); + if (term->cols > end->col) { + pixman_region32_union_rect( + ®ion, ®ion, + end->col, rel_end_row, + term->cols - end->col, 1); + } /* Full rows between end and start */ if (rel_end_row + 1 < rel_start_row) { -- cgit v1.3