summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-09-19 13:53:34 -0700
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-02-16 10:46:48 +0900
commit7c0dcc0f89813734253849b0e850cec88c82b34c (patch)
tree1bf51c202c40a2c74f51c9670015c2aab0c7e57a
parent01ec76b9eb113348c2811dead462eac319864d5f (diff)
downloaddiffutils-accepted/tizen_6.5_base.tar.gz
diffutils-accepted/tizen_6.5_base.tar.bz2
diffutils-accepted/tizen_6.5_base.zip
Problem reported by Hanno Böck in: http://bugs.gnu.org/21513 * lib/regcomp.c (parse_reg_exp): While parsing alternatives, keep track of the set of previously-completed subexpressions available before the first alternative, and restore this set just before parsing each subsequent alternative. This lets us diagnose the invalid back-reference in the ERE '()|\1'. Change-Id: I33d1ba3c5c4e3460b81cda46eac2a4eac625b8c3 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
-rw-r--r--lib/regcomp.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/regcomp.c b/lib/regcomp.c
index f7cfebe..63f08c1 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -2182,6 +2182,7 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
{
re_dfa_t *dfa = preg->buffer;
bin_tree_t *tree, *branch = NULL;
+ bitset_word_t initial_bkref_map = dfa->completed_bkref_map;
tree = parse_branch (regexp, preg, token, syntax, nest, err);
if (BE (*err != REG_NOERROR && tree == NULL, 0))
return NULL;
@@ -2192,9 +2193,16 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
if (token->type != OP_ALT && token->type != END_OF_RE
&& (nest == 0 || token->type != OP_CLOSE_SUBEXP))
{
+ bitset_word_t accumulated_bkref_map = dfa->completed_bkref_map;
+ dfa->completed_bkref_map = initial_bkref_map;
branch = parse_branch (regexp, preg, token, syntax, nest, err);
if (BE (*err != REG_NOERROR && branch == NULL, 0))
- return NULL;
+ {
+ if (tree != NULL)
+ postorder (tree, free_tree, NULL);
+ return NULL;
+ }
+ dfa->completed_bkref_map |= accumulated_bkref_map;
}
else
branch = NULL;