diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-06-22 22:06:12 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-06-22 22:06:12 +0300 |
commit | 7cdd5a510d45228574c34b066b2ddac833fef118 (patch) | |
tree | 8185af2a687f969ef280f139103028141b75f1dd | |
parent | 46b2d10640dc4404680fc7ffc670dd06feb5ecf3 (diff) | |
download | egawk-7cdd5a510d45228574c34b066b2ddac833fef118.tar.gz egawk-7cdd5a510d45228574c34b066b2ddac833fef118.tar.bz2 egawk-7cdd5a510d45228574c34b066b2ddac833fef118.zip |
Fix memory leak in regcomp.c.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | regcomp.c | 14 |
2 files changed, 21 insertions, 3 deletions
@@ -1,3 +1,13 @@ +2014-06-22 Paul Eggert <eggert@penguin.cs.ucla.edu> + + Bring in from GNULIB: + + regex: fix memory leak in compiler + Fix by Andreas Schwab in: + https://sourceware.org/ml/libc-alpha/2014-06/msg00462.html + * lib/regcomp.c (parse_expression): Deallocate partially + constructed tree before returning error. + 2014-06-19 Arnold D. Robbins <arnold@skeeve.com> * builtin.c (do_sub): Add more info to leading comment. @@ -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; } |