From: Paul Eggert Date: Fri, 11 Jul 2014 19:19:34 +0000 (-0700) Subject: regex: fix memory leak in compiler X-Git-Tag: v1.0~7335 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=c4093fa1648a0d2385c58d75c3140def7dcdebdf;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 02c667681e..0a7b82f958 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-07-11 Paul Eggert + + 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 announce-gen: avoid perl warnings diff --git a/lib/regcomp.c b/lib/regcomp.c index 16d0e21595..44c6c5ebb2 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;