aboutsummaryrefslogtreecommitdiff
path: root/posix/regcomp.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2010-10-11 11:46:22 -0400
committerUlrich Drepper <drepper@gmail.com>2010-10-11 11:46:22 -0400
commita129c80d54ec951567caa8c1b042275422d5f367 (patch)
tree1ed6df786f2883d65f45461a431c6041f002dbef /posix/regcomp.c
parentb76b818e6fe2061e778b3a9bbe63c554c3f9b3c1 (diff)
downloadglibc-a129c80d54ec951567caa8c1b042275422d5f367.tar
glibc-a129c80d54ec951567caa8c1b042275422d5f367.tar.gz
glibc-a129c80d54ec951567caa8c1b042275422d5f367.tar.bz2
glibc-a129c80d54ec951567caa8c1b042275422d5f367.zip
Fix memory leak for some invalid regular expressions.
Diffstat (limited to 'posix/regcomp.c')
-rw-r--r--posix/regcomp.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/posix/regcomp.c b/posix/regcomp.c
index 03ab123907..9f5ca2cd0e 100644
--- a/posix/regcomp.c
+++ b/posix/regcomp.c
@@ -2418,7 +2418,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;
}
@@ -3028,6 +3032,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;
}