From e27ea3337acea44d29f8e2888aef8a29c2c313ee Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 6 Jul 2018 09:50:34 +0530 Subject: [PATCH] Prevent integer wrap on xlimit --- kitty/screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kitty/screen.c b/kitty/screen.c index d1bf8c808..12babc22f 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1764,7 +1764,7 @@ screen_selection_range_for_line(Screen *self, index_type y, index_type *start, i index_type xlimit = line->xnum, xstart = 0; while (xlimit > 0 && CHAR_IS_BLANK(line->cpu_cells[xlimit - 1].ch)) xlimit--; while (xstart < xlimit && CHAR_IS_BLANK(line->cpu_cells[xstart].ch)) xstart++; - *start = xstart; *end = xlimit - 1; + *start = xstart; *end = xlimit > 0 ? xlimit - 1 : 0; return true; }