From a491abf24eea77376a10fd6c7b4b569d0c314599 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Thu, 3 Apr 2014 21:37:22 +0300 Subject: Minor code cleanup in regcomp.c. --- regcomp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'regcomp.c') diff --git a/regcomp.c b/regcomp.c index f3c4587d..776b7134 100644 --- a/regcomp.c +++ b/regcomp.c @@ -3128,8 +3128,8 @@ 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 (sbcset); re_free (mbcset); #endif *err = REG_ESPACE; -- cgit v1.2.3 From 7cdd5a510d45228574c34b066b2ddac833fef118 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 22 Jun 2014 22:06:12 +0300 Subject: Fix memory leak in regcomp.c. --- regcomp.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'regcomp.c') diff --git a/regcomp.c b/regcomp.c index 776b7134..a62364c9 100644 --- a/regcomp.c +++ b/regcomp.c @@ -2476,14 +2476,22 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM) { - tree = parse_dup_op (tree, regexp, dfa, token, syntax, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; + bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token, + syntax, err); + if (BE (*err != REG_NOERROR && dup_tree == NULL, 0)) + { + if (tree != NULL) + postorder (tree, free_tree, NULL); + return NULL; + } + tree = dup_tree; /* In BRE consecutive duplications are not allowed. */ if ((syntax & RE_CONTEXT_INVALID_DUP) && (token->type == OP_DUP_ASTERISK || token->type == OP_OPEN_DUP_NUM)) { + if (tree != NULL) + postorder (tree, free_tree, NULL); *err = REG_BADRPT; return NULL; } -- cgit v1.2.3