commit ee1a1306e29ca254ffb113011ca00a512656484d
parent db72774458151cfbf113f3177d0b2d39a6117f34
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 26 Feb 2024 13:10:04 +0100
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.
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git 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;