From c4093fa1648a0d2385c58d75c3140def7dcdebdf Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 11 Jul 2014 12:19:34 -0700 Subject: [PATCH] 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. --- ChangeLog | 8 ++++++++ lib/regcomp.c | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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; -- 2.39.5