From 487b0ee124363f838bfd5dcc1dcccd4db22f414a Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 25 Oct 2024 15:19:15 +0000 Subject: [PATCH] Do not attempt to search for zero length strings, from Alexander Arch in GitHub issue 4209. --- window-copy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/window-copy.c b/window-copy.c index 4e8f947b..7a2734ac 100644 --- a/window-copy.c +++ b/window-copy.c @@ -3701,7 +3701,7 @@ window_copy_search(struct window_mode_entry *wme, int direction, int regex) struct screen_write_ctx ctx; struct grid *gd = s->grid; const char *str = data->searchstr; - u_int at, endline, fx, fy, start; + u_int at, endline, fx, fy, start, ssx; int cis, found, keys, visible_only; int wrapflag; @@ -3728,7 +3728,9 @@ window_copy_search(struct window_mode_entry *wme, int direction, int regex) fx = data->cx; fy = screen_hsize(data->backing) - data->oy + data->cy; - screen_init(&ss, screen_write_strlen("%s", str), 1, 0); + if ((ssx = screen_write_strlen("%s", str)) == 0) + return (0); + screen_init(&ss, ssx, 1, 0); screen_write_start(&ctx, &ss); screen_write_nputs(&ctx, -1, &grid_default_cell, "%s", str); screen_write_stop(&ctx);