aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2010-10-11 11:46:22 -0400
committerAndreas Schwab <schwab@redhat.com>2010-12-01 15:35:13 +0100
commitac25f45efaf8123d5474686108d580aac4bc14ff (patch)
tree43c59a7d7ee8753949013b0c24396959cd679adf
parenta0ad547936d671e7dffe53fb119f9066c351a30a (diff)
downloadglibc-ac25f45efaf8123d5474686108d580aac4bc14ff.zip
glibc-ac25f45efaf8123d5474686108d580aac4bc14ff.tar.gz
glibc-ac25f45efaf8123d5474686108d580aac4bc14ff.tar.bz2
Fix memory leak for some invalid regular expressions.
(cherry picked from commit a129c80d54ec951567caa8c1b042275422d5f367)
-rw-r--r--ChangeLog7
-rw-r--r--posix/regcomp.c10
2 files changed, 16 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0d020c8..85df144 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2010-10-11 Ulrich Drepper <drepper@gmail.com>
+ * 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.
+
+2010-10-11 Ulrich Drepper <drepper@gmail.com>
+
[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 03ab123..9f5ca2c 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;
}