diff options
author | Paolo Bonzini <bonzini@gnu.org> | 2005-02-10 09:38:11 +0000 |
---|---|---|
committer | Paolo Bonzini <bonzini@gnu.org> | 2008-01-09 16:11:48 +0100 |
commit | 20a67b75e7b8c2ba418edc9eac092d332dd39741 (patch) | |
tree | 722b3500ff0e4110d2bc24d408d57609f1968fbd /lib | |
parent | 93f1e336c39a39e1c8be86ce8b525fbdaf58e99f (diff) | |
download | sed-20a67b75e7b8c2ba418edc9eac092d332dd39741.tar.gz |
fix crash on /\(\)/x
2005-02-10 Paolo Bonzini <bonzini@gnu.org>
* lib/regcomp.c (lower_subexp): Do not optimize empty
subexpressions even with REG_NOSUB.
* testsuite/SPENCER.tests: Add a previously failing testcase.
git-archimport-id: bonzini@gnu.org--2004b/sed--stable--4.1--patch-43
Diffstat (limited to 'lib')
-rw-r--r-- | lib/regcomp.c | 5 | ||||
-rw-r--r-- | lib/regex_internal.h | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/regcomp.c b/lib/regcomp.c index 1a5f795..4fe5d5c 100644 --- a/lib/regcomp.c +++ b/lib/regcomp.c @@ -1321,6 +1321,11 @@ lower_subexp (err, preg, node) bin_tree_t *op, *cls, *tree1, *tree; if (preg->no_sub + /* We do not optimize empty subexpressions, because otherwise we may + have bad CONCAT nodes with NULL children. This is obviously not + very common, so we do not lose much. An example that triggers + this case is the sed "script" /\(\)/x. */ + && node->left && (node->token.opr.idx >= 8 * sizeof (dfa->used_bkref_map) || !(dfa->used_bkref_map & (1 << node->token.opr.idx)))) return node->left; diff --git a/lib/regex_internal.h b/lib/regex_internal.h index f065cf4..299c6e9 100644 --- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -629,6 +629,7 @@ struct re_dfa_t int nbackref; /* The number of backreference in this dfa. */ /* Bitmap expressing which backreference is used. */ + unsigned int empty_bkref_map; unsigned int used_bkref_map; unsigned int completed_bkref_map; |