From bd5771ff27dbbb2b09cc7c14f1ac040234285acc Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 26 Aug 2020 00:07:08 -0700 Subject: [PATCH] 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. --- src/regex-emacs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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);\ } -- 2.39.2