bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] regex: fix memory leak in compiler


From: Paul Eggert
Subject: [PATCH] regex: fix memory leak in compiler
Date: Fri, 11 Jul 2014 12:21:06 -0700

Fix by Andreas Schwab in:
https://sourceware.org/ml/libc-alpha/2014-06/msg00503.html
* lib/regcomp.c (parse_reg_exp): Deallocate partially
constructed tree before returning error.
---
 ChangeLog     | 8 ++++++++
 lib/regcomp.c | 6 +++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 02c6676..0a7b82f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-07-11  Paul Eggert  <address@hidden>
+
+       regex: fix memory leak in compiler
+       Fix by Andreas Schwab in:
+       https://sourceware.org/ml/libc-alpha/2014-06/msg00503.html
+       * lib/regcomp.c (parse_reg_exp): Deallocate partially
+       constructed tree before returning error.
+
 2014-07-10  Assaf Gordon  <address@hidden>
 
        announce-gen: avoid perl warnings
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 16d0e21..44c6c5e 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -2199,7 +2199,11 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, 
re_token_t *token,
        {
          branch = parse_branch (regexp, preg, token, syntax, nest, err);
          if (BE (*err != REG_NOERROR && branch == NULL, 0))
-           return NULL;
+           {
+             if (tree != NULL)
+               postorder (tree, free_tree, NULL);
+             return NULL;
+           }
        }
       else
        branch = NULL;
-- 
1.9.3




reply via email to

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