From: Ulrich Drepper Date: Mon, 11 Oct 2010 15:46:22 +0000 (-0400) Subject: Fix memory leak for some invalid regular expressions. X-Git-Tag: glibc-2.11.3~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a69e300d5529d84bff72b17eeaaf9140e44052d;p=thirdparty%2Fglibc.git Fix memory leak for some invalid regular expressions. (cherry picked from commit a129c80d54ec951567caa8c1b042275422d5f367) --- diff --git a/ChangeLog b/ChangeLog index 73cd52856d6..a35f75ac7ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2010-10-11 Ulrich Drepper + * posix/regcomp.c (parse_bracket_exp): Add missing re_free calls. + + [BZ #12078] + * posix/regcomp.c (parse_sub_exp): Free tree data when it is not used. + [BZ #12093] * sysdeps/unix/sysv/linux/check_pf.c (__check_pf): ->ifa_addr might be NULL. diff --git a/posix/regcomp.c b/posix/regcomp.c index 542b848f141..e70de870bcb 100644 --- a/posix/regcomp.c +++ b/posix/regcomp.c @@ -2412,7 +2412,11 @@ parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, { tree = parse_reg_exp (regexp, preg, token, syntax, nest, err); if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0)) - *err = REG_EPAREN; + { + if (tree != NULL) + free_tree (NULL, tree); + *err = REG_EPAREN; + } if (BE (*err != REG_NOERROR, 0)) return NULL; } @@ -3022,6 +3026,10 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, if (BE (sbcset == NULL, 0)) #endif /* RE_ENABLE_I18N */ { + re_free (sbcset); +#ifdef RE_ENABLE_I18N + re_free (mbcset); +#endif *err = REG_ESPACE; return NULL; }