]> Savannah Git Hosting - gnulib.git/commitdiff
regex: fix memory leak in compiler
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 11 Jul 2014 19:19:34 +0000 (12:19 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 11 Jul 2014 19:20:02 +0000 (12:20 -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
lib/regcomp.c

index 02c667681ef0dd525a078659345a41d8c07360ba..0a7b82f958c320870a74238ee1a87b14f9ddff42 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-07-11  Paul Eggert  <eggert@cs.ucla.edu>
+
+       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  <assafgordon@gmail.com>
 
        announce-gen: avoid perl warnings
index 16d0e2159519a130c17d6bf1da6faceae4c43d06..44c6c5ebb2c19254bdabed4138ea49e13bcb27f0 100644 (file)
@@ -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;