summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-08-26 00:07:08 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-08-26 00:20:31 -0700
commitbd5771ff27dbbb2b09cc7c14f1ac040234285acc (patch)
tree3a1fc95feed46fd6557397b92d5c05773c13c294 /src
parent4c0a9754ace421461d648b911da6d5eec49e9a62 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/regex-emacs.c6
1 files changed, 5 insertions, 1 deletions
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);\
}