From 751fa603d386915cf1114c937892bd30e86ea687 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Sat, 27 Dec 2014 19:03:50 +0100 Subject: [PATCH] Fix infinite loop when regexp-matching an empty string See Debian bug https://bugs.debian.org/358389 --- src/video.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/video.c b/src/video.c index cfcd417..52a3615 100644 --- a/src/video.c +++ b/src/video.c @@ -293,6 +293,20 @@ info_add_highlights(int pos, int cursor, long lines, int column, char **message) /* yes, found something, so highlight it */ int n = pmatch[0].rm_eo - pmatch[0].rm_so; + if (n==0) { /* matched empty string! */ + /* display error message */ + char msg[81]; + snprintf(msg, 81, "%s", + _("Warning: matched empty string") ); + attrset(bottomline); + mvhline(maxy - 1, 0, ' ', maxx); + mvaddstr(maxy - 1, 0, msg); + move(0, 0); + attrset(normal); + + break; + } + /* point str at start of match */ str += pmatch[0].rm_so; -- 2.33.0