From: Paul Eggert Date: Wed, 26 Aug 2020 07:07:08 +0000 (-0700) Subject: regex-emacs: fix leak on memory allocation failure X-Git-Tag: emacs-28.0.90~6394 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bd5771ff27dbbb2b09cc7c14f1ac040234285acc;p=emacs.git regex-emacs: fix leak on memory allocation failure * src/regex-emacs.c (ENSURE_FAIL_STACK): If the failure stack cannot be grown, free locally-allocated storage before returning. --- diff --git a/src/regex-emacs.c b/src/regex-emacs.c index 5d1bb094d53..3d8aaf4bb13 100644 --- a/src/regex-emacs.c +++ b/src/regex-emacs.c @@ -969,7 +969,11 @@ typedef struct #define ENSURE_FAIL_STACK(space) \ while (REMAINING_AVAIL_SLOTS <= space) { \ if (!GROW_FAIL_STACK (fail_stack)) \ - return -2; \ + { \ + unbind_to (count, Qnil); \ + SAFE_FREE (); \ + return -2; \ + } \ DEBUG_PRINT ("\n Doubled stack; size now: %td\n", fail_stack.size); \ DEBUG_PRINT (" slots available: %td\n", REMAINING_AVAIL_SLOTS);\ }