From ee1a1306e29ca254ffb113011ca00a512656484d Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 26 Feb 2024 13:10:04 +0100 Subject: [PATCH] search: avoid crashing after searching a help text during a regex replace Searching in a help text does not support using regular expressions, so when 'inhelp' is set, do not free a compiled regex -- because if there is such a regex, it belongs to a replacement session that is about to begin. This fixes https://savannah.gnu.org/bugs/?65369. The issue was reported by `correctmost`. Bug existed since version 2.8.2, since searching in a help text became possible. --- src/search.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/search.c b/src/search.c index 6b2a0c02..aea37e4d 100644 --- a/src/search.c +++ b/src/search.c @@ -57,6 +57,10 @@ bool regexp_init(const char *regexp) * full screen refresh when the mark is on, in case the cursor has moved. */ void tidy_up_after_search(void) { + /* Searching in a help text does not support regular expressions. */ + if (inhelp) + return; + if (have_compiled_regexp) { regfree(&search_regexp); have_compiled_regexp = FALSE;