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.
This commit is contained in:
Benno Schulenberg 2024-02-26 13:10:04 +01:00
parent db72774458
commit ee1a1306e2

View File

@ -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;