]> git.eshelyaron.com Git - emacs.git/commitdiff
regex-emacs: fix leak on memory allocation failure
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 26 Aug 2020 07:07:08 +0000 (00:07 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 26 Aug 2020 07:20:31 +0000 (00:20 -0700)
* src/regex-emacs.c (ENSURE_FAIL_STACK): If the failure
stack cannot be grown, free locally-allocated storage
before returning.

src/regex-emacs.c

index 5d1bb094d534979c56662be446304164ededee1c..3d8aaf4bb1350c14e7b89fe01f2f28e7a02732ea 100644 (file)
@@ -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);\
 }