From f3ebeb35f3773b2e5523da6af25c8021816cfc06 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 15 Oct 2018 14:26:50 +0000 Subject: [PATCH 353/693] Another proposed fix for [4b555aca34]: text search -all hangs and eats all memory. --- generic/tkText.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/generic/tkText.c b/generic/tkText.c index d43bef6b0..715e3c045 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5749,11 +5749,16 @@ SearchCore( /* * We only need to set the matchLength once for exact searches, and we * do it here. It is also used below as the actual pattern length, so - * it has dual purpose. + * it has dual purpose. Warning: to properly advance between matches + * the matchLength can't be zero (which would happen when searching + * for an empty string). */ pattern = Tcl_GetString(patObj); matchLength = patObj->length; + if (matchLength == 0) { + matchLength = 1; + } nl = strchr(pattern, '\n'); /* -- 2.19.1