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 /regcomp.c | |
parent | 46b2d10640dc4404680fc7ffc670dd06feb5ecf3 (diff) | |
download | egawk-7cdd5a510d45228574c34b066b2ddac833fef118.tar.gz egawk-7cdd5a510d45228574c34b066b2ddac833fef118.tar.bz2 egawk-7cdd5a510d45228574c34b066b2ddac833fef118.zip |
Fix memory leak in regcomp.c.
Diffstat (limited to 'regcomp.c')
-rw-r--r-- | regcomp.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -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; } |