From 41151ac50d8cf928ca2ff75fea328ef9869b44b7 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Thu, 15 Jan 2004 05:47:03 +0000 Subject: [PATCH] add DB's fix for a do_replace_loop() segfault git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1627 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/search.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ff460eb5..06a252f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,11 @@ CVS code - - Move the call to raw() on systems that don't define _POSIX_VDISABLE outside the main input/output loop, as it doesn't need to be called every time through the loop. (DLR) +- search.c: + do_replace_loop() + - Fix segfault when doing a regex replace of a string that + matches inside a line (e.g. replace the "b" in "abc" with + anything). (David Benbennick) - winio.c: do_credits() - Use nanosleep() instead of usleep(). The latter is only diff --git a/src/search.c b/src/search.c index 51d73aa1..69f9eba2 100644 --- a/src/search.c +++ b/src/search.c @@ -722,7 +722,7 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin, #ifdef HAVE_REGEX_H /* Set the bol_eol flag if we're doing a bol and/or eol regex * replace ("^", "$", or "^$"). */ - if (ISSET(USE_REGEXP) && regexec(&search_regexp, prevanswer, 1, NULL, REG_NOTBOL | REG_NOTEOL) == REG_NOMATCH) + if (ISSET(USE_REGEXP) && regexec(&search_regexp, prevanswer, 0, NULL, REG_NOTBOL | REG_NOTEOL) == REG_NOMATCH) bol_eol = 1; #endif -- 2.39.5