mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
found a nasty bug in regexp automata build, reported by Ashwin and Bjorn
* xmlregexp.c: found a nasty bug in regexp automata build, reported by Ashwin and Bjorn Reese Daniel svn path=/trunk/; revision=3705
This commit is contained in:
23
xmlregexp.c
23
xmlregexp.c
@ -1532,6 +1532,8 @@ xmlFAGenerateCountedTransition(xmlRegParserCtxtPtr ctxt,
|
||||
static int
|
||||
xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
|
||||
xmlRegStatePtr to, xmlRegAtomPtr atom) {
|
||||
xmlRegStatePtr end;
|
||||
|
||||
if (atom == NULL) {
|
||||
ERROR("genrate transition: atom == NULL");
|
||||
return(-1);
|
||||
@ -1689,12 +1691,31 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
|
||||
else {
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
end = to;
|
||||
if ((atom->quant == XML_REGEXP_QUANT_MULT) ||
|
||||
(atom->quant == XML_REGEXP_QUANT_PLUS)) {
|
||||
/*
|
||||
* Do not pollute the target state by adding transitions from
|
||||
* it as it is likely to be the shared target of multiple branches.
|
||||
* So isolate with an epsilon transition.
|
||||
*/
|
||||
xmlRegStatePtr tmp;
|
||||
|
||||
tmp = xmlRegNewState(ctxt);
|
||||
if (tmp != NULL)
|
||||
xmlRegStatePush(ctxt, tmp);
|
||||
else {
|
||||
return(-1);
|
||||
}
|
||||
xmlFAGenerateEpsilonTransition(ctxt, tmp, to);
|
||||
to = tmp;
|
||||
}
|
||||
if (xmlRegAtomPush(ctxt, atom) < 0) {
|
||||
return(-1);
|
||||
}
|
||||
xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1);
|
||||
ctxt->state = to;
|
||||
ctxt->state = end;
|
||||
switch (atom->quant) {
|
||||
case XML_REGEXP_QUANT_OPT:
|
||||
atom->quant = XML_REGEXP_QUANT_ONCE;
|
||||
|
Reference in New Issue
Block a user