diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2024-10-25 15:19:16 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2024-10-25 15:19:16 +0000 |
commit | 0620ee63e56596a83efbce36c7496dc70a74c8b1 (patch) | |
tree | 363d7f68b3075819413c66745d68695bc20231fe /usr.bin | |
parent | ae9ba25cfc7f852a93c1d98f48a0be5998cd2ee6 (diff) |
Do not attempt to search for zero length strings, from Alexander Arch in
GitHub issue 4209.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/window-copy.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index d07dc2aee5d..6b703d55f0c 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.360 2024/10/25 15:13:10 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.361 2024/10/25 15:19:15 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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); |