From d6aa55e2b48d56bf9a2cd25176029b6fb80a80b2 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 22 Jun 2018 15:57:47 +0300 Subject: [PATCH] Avoid segfaults in replace-buffer-contents with large buffers * src/editfns.c (Freplace_buffer_contents): Don't release malloc'ed memory as long as we are using it. (Bug#31888) --- src/editfns.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/editfns.c b/src/editfns.c index fc5b6c117f5..d15ae59029d 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3215,7 +3215,6 @@ buffer stay intact. */) /* Since we didn’t define EARLY_ABORT, we should never abort early. */ eassert (! early_abort); - SAFE_FREE (); Fundo_boundary (); ptrdiff_t count = SPECPDL_INDEX (); @@ -3261,8 +3260,10 @@ buffer stay intact. */) --i; --j; } + unbind_to (count, Qnil); + SAFE_FREE (); - return unbind_to (count, Qnil); + return Qnil; } static void -- 2.11.4.GIT