summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2020-05-16 16:03:57 +0000
committernicm <nicm@openbsd.org>2020-05-16 16:03:57 +0000
commit70759ebb5842289fd3ac92449f0d018e526a3d35 (patch)
tree7e1186ad1ed89b8dacc0c8f201283daa9c495efd
parentFix next-matching-bracket logic, from Chris Barber. (diff)
downloadwireguard-openbsd-70759ebb5842289fd3ac92449f0d018e526a3d35.tar.xz
wireguard-openbsd-70759ebb5842289fd3ac92449f0d018e526a3d35.zip
Do not loop forever when search finds an empty match, GitHub issue 2203.
-rw-r--r--usr.bin/tmux/window-copy.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index 218f50bebfd..bf047593737 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.286 2020/05/16 16:03:30 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.287 2020/05/16 16:03:57 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -2445,7 +2445,8 @@ window_copy_search_lr_regex(struct grid *gd, u_int *ppx, u_int *psx, u_int py,
len += gd->sx;
}
- if (regexec(reg, buf, 1, &regmatch, eflags) == 0) {
+ if (regexec(reg, buf, 1, &regmatch, eflags) == 0 &&
+ regmatch.rm_so != regmatch.rm_eo) {
foundx = first;
foundy = py;
window_copy_cstrtocellpos(gd, len, &foundx, &foundy,
@@ -2547,6 +2548,8 @@ window_copy_last_regex(struct grid *gd, u_int py, u_int first, u_int last,
foundy = py;
oldx = first;
while (regexec(preg, buf + px, 1, &regmatch, eflags) == 0) {
+ if (regmatch.rm_so == regmatch.rm_eo)
+ break;
window_copy_cstrtocellpos(gd, len, &foundx, &foundy,
buf + px + regmatch.rm_so);
if (foundy > py || foundx >= last)