diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2021-12-20 00:34:58 +0100 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2022-02-28 16:56:02 +0100 |
commit | ea6e8f998dc1a4d465fb8d44c4fad93940ca8280 (patch) | |
tree | ed06f98a1e139d9fbb74491b57241c8c6d184720 /xmlregexp.c | |
parent | 382fb056b59c9b54e3d4bf8f2329f3bc5c7d40e0 (diff) | |
download | libxml2-ea6e8f998dc1a4d465fb8d44c4fad93940ca8280.tar.gz |
Fix certain combinations of regex range quantifiers
Fix regex transitions that have both min/max and a counter. In this
case, we want to save the regex state before incrementing the counter.
Fixes #301 and the issue reported here:
https://mail.gnome.org/archives/xml/2016-April/msg00017.html
Diffstat (limited to 'xmlregexp.c')
-rw-r--r-- | xmlregexp.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/xmlregexp.c b/xmlregexp.c index 80dfc34a..784563af 100644 --- a/xmlregexp.c +++ b/xmlregexp.c @@ -3364,7 +3364,6 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) { /* * this is a multiple input sequence * If there is a counter associated increment it now. - * before potentially saving and rollback * do not increment if the counter is already over the * maximum limit in which case get to next transition */ @@ -3380,15 +3379,17 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) { counter = &exec->comp->counters[trans->counter]; if (exec->counts[trans->counter] >= counter->max) continue; /* for loop on transitions */ - + } + /* Save before incrementing */ + if (exec->state->nbTrans > exec->transno + 1) { + xmlFARegExecSave(exec); + } + if (trans->counter >= 0) { #ifdef DEBUG_REGEXP_EXEC printf("Increasing count %d\n", trans->counter); #endif exec->counts[trans->counter]++; } - if (exec->state->nbTrans > exec->transno + 1) { - xmlFARegExecSave(exec); - } exec->transcount = 1; do { /* |