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:
@ -1,3 +1,8 @@
|
|||||||
|
Thu Mar 13 08:17:58 CET 2008 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* xmlregexp.c: found a nasty bug in regexp automata build,
|
||||||
|
reported by Ashwin and Bjorn Reese
|
||||||
|
|
||||||
Wed Mar 12 18:56:22 CET 2008 Daniel Veillard <daniel@veillard.com>
|
Wed Mar 12 18:56:22 CET 2008 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* HTMLparser.c: patch from Arnold Hendriks improving parsing of
|
* HTMLparser.c: patch from Arnold Hendriks improving parsing of
|
||||||
|
23
xmlregexp.c
23
xmlregexp.c
@ -1532,6 +1532,8 @@ xmlFAGenerateCountedTransition(xmlRegParserCtxtPtr ctxt,
|
|||||||
static int
|
static int
|
||||||
xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
|
xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
|
||||||
xmlRegStatePtr to, xmlRegAtomPtr atom) {
|
xmlRegStatePtr to, xmlRegAtomPtr atom) {
|
||||||
|
xmlRegStatePtr end;
|
||||||
|
|
||||||
if (atom == NULL) {
|
if (atom == NULL) {
|
||||||
ERROR("genrate transition: atom == NULL");
|
ERROR("genrate transition: atom == NULL");
|
||||||
return(-1);
|
return(-1);
|
||||||
@ -1689,12 +1691,31 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
|
|||||||
else {
|
else {
|
||||||
return(-1);
|
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) {
|
if (xmlRegAtomPush(ctxt, atom) < 0) {
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1);
|
xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1);
|
||||||
ctxt->state = to;
|
ctxt->state = end;
|
||||||
switch (atom->quant) {
|
switch (atom->quant) {
|
||||||
case XML_REGEXP_QUANT_OPT:
|
case XML_REGEXP_QUANT_OPT:
|
||||||
atom->quant = XML_REGEXP_QUANT_ONCE;
|
atom->quant = XML_REGEXP_QUANT_ONCE;
|
||||||
|
Reference in New Issue
Block a user