emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master bd5771f 5/6: regex-emacs: fix leak on memory allocation failure


From: Paul Eggert
Subject: master bd5771f 5/6: regex-emacs: fix leak on memory allocation failure
Date: Wed, 26 Aug 2020 03:20:39 -0400 (EDT)

branch: master
commit bd5771ff27dbbb2b09cc7c14f1ac040234285acc
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>

    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 5d1bb09..3d8aaf4 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);\
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]