153aa9179Sopenharmony_ciFrom e60c9f4c4b76da72772bfb6bb1f705e02fbb5324 Mon Sep 17 00:00:00 2001
253aa9179Sopenharmony_ciFrom: Nick Wellnhofer <wellnhofer@aevum.de>
353aa9179Sopenharmony_ciDate: Wed, 15 Feb 2023 01:00:03 +0100
453aa9179Sopenharmony_ciSubject: [PATCH] malloc-fail: Fix memory leak after xmlRegNewState
553aa9179Sopenharmony_ci
653aa9179Sopenharmony_ciInvoke xmlRegNewState from xmlRegStatePush to simplify error handling.
753aa9179Sopenharmony_ci
853aa9179Sopenharmony_ciFound with libFuzzer, see #344.
953aa9179Sopenharmony_ci
1053aa9179Sopenharmony_ciReference:https://github.com/GNOME/libxml2/commit/e60c9f4c4b76da72772bfb6bb1f705e02fbb5324
1153aa9179Sopenharmony_ciConflict:NA
1253aa9179Sopenharmony_ci---
1353aa9179Sopenharmony_ci xmlregexp.c | 144 ++++++++++++++++++++++++++--------------------------
1453aa9179Sopenharmony_ci 1 file changed, 71 insertions(+), 73 deletions(-)
1553aa9179Sopenharmony_ci
1653aa9179Sopenharmony_cidiff --git a/xmlregexp.c b/xmlregexp.c
1753aa9179Sopenharmony_ciindex 657912e..fb2eadc 100644
1853aa9179Sopenharmony_ci--- a/xmlregexp.c
1953aa9179Sopenharmony_ci+++ b/xmlregexp.c
2053aa9179Sopenharmony_ci@@ -1455,33 +1455,31 @@ xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
2153aa9179Sopenharmony_ci     xmlRegStateAddTransTo(ctxt, target, state->no);
2253aa9179Sopenharmony_ci }
2353aa9179Sopenharmony_ci 
2453aa9179Sopenharmony_ci-static int
2553aa9179Sopenharmony_ci-xmlRegStatePush(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state) {
2653aa9179Sopenharmony_ci-    if (state == NULL) return(-1);
2753aa9179Sopenharmony_ci-    if (ctxt->maxStates == 0) {
2853aa9179Sopenharmony_ci-	ctxt->maxStates = 4;
2953aa9179Sopenharmony_ci-	ctxt->states = (xmlRegStatePtr *) xmlMalloc(ctxt->maxStates *
3053aa9179Sopenharmony_ci-		                             sizeof(xmlRegStatePtr));
3153aa9179Sopenharmony_ci-	if (ctxt->states == NULL) {
3253aa9179Sopenharmony_ci-	    xmlRegexpErrMemory(ctxt, "adding state");
3353aa9179Sopenharmony_ci-	    ctxt->maxStates = 0;
3453aa9179Sopenharmony_ci-	    return(-1);
3553aa9179Sopenharmony_ci-	}
3653aa9179Sopenharmony_ci-    } else if (ctxt->nbStates >= ctxt->maxStates) {
3753aa9179Sopenharmony_ci+static xmlRegStatePtr
3853aa9179Sopenharmony_ci+xmlRegStatePush(xmlRegParserCtxtPtr ctxt) {
3953aa9179Sopenharmony_ci+    xmlRegStatePtr state;
4053aa9179Sopenharmony_ci+
4153aa9179Sopenharmony_ci+    if (ctxt->nbStates >= ctxt->maxStates) {
4253aa9179Sopenharmony_ci+        size_t newSize = ctxt->maxStates ? ctxt->maxStates * 2 : 4;
4353aa9179Sopenharmony_ci 	xmlRegStatePtr *tmp;
4453aa9179Sopenharmony_ci-	ctxt->maxStates *= 2;
4553aa9179Sopenharmony_ci-	tmp = (xmlRegStatePtr *) xmlRealloc(ctxt->states, ctxt->maxStates *
4653aa9179Sopenharmony_ci-		                             sizeof(xmlRegStatePtr));
4753aa9179Sopenharmony_ci+
4853aa9179Sopenharmony_ci+	tmp = xmlRealloc(ctxt->states, newSize * sizeof(tmp[0]));
4953aa9179Sopenharmony_ci 	if (tmp == NULL) {
5053aa9179Sopenharmony_ci 	    xmlRegexpErrMemory(ctxt, "adding state");
5153aa9179Sopenharmony_ci-	    ctxt->maxStates /= 2;
5253aa9179Sopenharmony_ci-	    return(-1);
5353aa9179Sopenharmony_ci+	    return(NULL);
5453aa9179Sopenharmony_ci 	}
5553aa9179Sopenharmony_ci 	ctxt->states = tmp;
5653aa9179Sopenharmony_ci+	ctxt->maxStates = newSize;
5753aa9179Sopenharmony_ci     }
5853aa9179Sopenharmony_ci+
5953aa9179Sopenharmony_ci+    state = xmlRegNewState(ctxt);
6053aa9179Sopenharmony_ci+    if (state == NULL)
6153aa9179Sopenharmony_ci+        return(NULL);
6253aa9179Sopenharmony_ci+
6353aa9179Sopenharmony_ci     state->no = ctxt->nbStates;
6453aa9179Sopenharmony_ci     ctxt->states[ctxt->nbStates++] = state;
6553aa9179Sopenharmony_ci-    return(0);
6653aa9179Sopenharmony_ci+
6753aa9179Sopenharmony_ci+    return(state);
6853aa9179Sopenharmony_ci }
6953aa9179Sopenharmony_ci 
7053aa9179Sopenharmony_ci /**
7153aa9179Sopenharmony_ci@@ -1492,19 +1490,21 @@ xmlRegStatePush(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state) {
7253aa9179Sopenharmony_ci  * @lax:
7353aa9179Sopenharmony_ci  *
7453aa9179Sopenharmony_ci  */
7553aa9179Sopenharmony_ci-static void
7653aa9179Sopenharmony_ci+static int
7753aa9179Sopenharmony_ci xmlFAGenerateAllTransition(xmlRegParserCtxtPtr ctxt,
7853aa9179Sopenharmony_ci 			   xmlRegStatePtr from, xmlRegStatePtr to,
7953aa9179Sopenharmony_ci 			   int lax) {
8053aa9179Sopenharmony_ci     if (to == NULL) {
8153aa9179Sopenharmony_ci-	to = xmlRegNewState(ctxt);
8253aa9179Sopenharmony_ci-	xmlRegStatePush(ctxt, to);
8353aa9179Sopenharmony_ci+	to = xmlRegStatePush(ctxt);
8453aa9179Sopenharmony_ci+        if (to == NULL)
8553aa9179Sopenharmony_ci+            return(-1);
8653aa9179Sopenharmony_ci 	ctxt->state = to;
8753aa9179Sopenharmony_ci     }
8853aa9179Sopenharmony_ci     if (lax)
8953aa9179Sopenharmony_ci 	xmlRegStateAddTrans(ctxt, from, NULL, to, -1, REGEXP_ALL_LAX_COUNTER);
9053aa9179Sopenharmony_ci     else
9153aa9179Sopenharmony_ci 	xmlRegStateAddTrans(ctxt, from, NULL, to, -1, REGEXP_ALL_COUNTER);
9253aa9179Sopenharmony_ci+    return(0);
9353aa9179Sopenharmony_ci }
9453aa9179Sopenharmony_ci 
9553aa9179Sopenharmony_ci /**
9653aa9179Sopenharmony_ci@@ -1514,15 +1514,17 @@ xmlFAGenerateAllTransition(xmlRegParserCtxtPtr ctxt,
9753aa9179Sopenharmony_ci  * @to:  the target state or NULL for building a new one
9853aa9179Sopenharmony_ci  *
9953aa9179Sopenharmony_ci  */
10053aa9179Sopenharmony_ci-static void
10153aa9179Sopenharmony_ci+static int
10253aa9179Sopenharmony_ci xmlFAGenerateEpsilonTransition(xmlRegParserCtxtPtr ctxt,
10353aa9179Sopenharmony_ci 			       xmlRegStatePtr from, xmlRegStatePtr to) {
10453aa9179Sopenharmony_ci     if (to == NULL) {
10553aa9179Sopenharmony_ci-	to = xmlRegNewState(ctxt);
10653aa9179Sopenharmony_ci-	xmlRegStatePush(ctxt, to);
10753aa9179Sopenharmony_ci+	to = xmlRegStatePush(ctxt);
10853aa9179Sopenharmony_ci+        if (to == NULL)
10953aa9179Sopenharmony_ci+            return(-1);
11053aa9179Sopenharmony_ci 	ctxt->state = to;
11153aa9179Sopenharmony_ci     }
11253aa9179Sopenharmony_ci     xmlRegStateAddTrans(ctxt, from, NULL, to, -1, -1);
11353aa9179Sopenharmony_ci+    return(0);
11453aa9179Sopenharmony_ci }
11553aa9179Sopenharmony_ci 
11653aa9179Sopenharmony_ci /**
11753aa9179Sopenharmony_ci@@ -1533,15 +1535,17 @@ xmlFAGenerateEpsilonTransition(xmlRegParserCtxtPtr ctxt,
11853aa9179Sopenharmony_ci  * counter:  the counter for that transition
11953aa9179Sopenharmony_ci  *
12053aa9179Sopenharmony_ci  */
12153aa9179Sopenharmony_ci-static void
12253aa9179Sopenharmony_ci+static int
12353aa9179Sopenharmony_ci xmlFAGenerateCountedEpsilonTransition(xmlRegParserCtxtPtr ctxt,
12453aa9179Sopenharmony_ci 	    xmlRegStatePtr from, xmlRegStatePtr to, int counter) {
12553aa9179Sopenharmony_ci     if (to == NULL) {
12653aa9179Sopenharmony_ci-	to = xmlRegNewState(ctxt);
12753aa9179Sopenharmony_ci-	xmlRegStatePush(ctxt, to);
12853aa9179Sopenharmony_ci+	to = xmlRegStatePush(ctxt);
12953aa9179Sopenharmony_ci+        if (to == NULL)
13053aa9179Sopenharmony_ci+            return(-1);
13153aa9179Sopenharmony_ci 	ctxt->state = to;
13253aa9179Sopenharmony_ci     }
13353aa9179Sopenharmony_ci     xmlRegStateAddTrans(ctxt, from, NULL, to, counter, -1);
13453aa9179Sopenharmony_ci+    return(0);
13553aa9179Sopenharmony_ci }
13653aa9179Sopenharmony_ci 
13753aa9179Sopenharmony_ci /**
13853aa9179Sopenharmony_ci@@ -1552,15 +1556,17 @@ xmlFAGenerateCountedEpsilonTransition(xmlRegParserCtxtPtr ctxt,
13953aa9179Sopenharmony_ci  * counter:  the counter for that transition
14053aa9179Sopenharmony_ci  *
14153aa9179Sopenharmony_ci  */
14253aa9179Sopenharmony_ci-static void
14353aa9179Sopenharmony_ci+static int
14453aa9179Sopenharmony_ci xmlFAGenerateCountedTransition(xmlRegParserCtxtPtr ctxt,
14553aa9179Sopenharmony_ci 	    xmlRegStatePtr from, xmlRegStatePtr to, int counter) {
14653aa9179Sopenharmony_ci     if (to == NULL) {
14753aa9179Sopenharmony_ci-	to = xmlRegNewState(ctxt);
14853aa9179Sopenharmony_ci-	xmlRegStatePush(ctxt, to);
14953aa9179Sopenharmony_ci+	to = xmlRegStatePush(ctxt);
15053aa9179Sopenharmony_ci+        if (to == NULL)
15153aa9179Sopenharmony_ci+            return(-1);
15253aa9179Sopenharmony_ci 	ctxt->state = to;
15353aa9179Sopenharmony_ci     }
15453aa9179Sopenharmony_ci     xmlRegStateAddTrans(ctxt, from, NULL, to, -1, counter);
15553aa9179Sopenharmony_ci+    return(0);
15653aa9179Sopenharmony_ci }
15753aa9179Sopenharmony_ci 
15853aa9179Sopenharmony_ci /**
15953aa9179Sopenharmony_ci@@ -1599,8 +1605,9 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
16053aa9179Sopenharmony_ci #ifdef DV
16153aa9179Sopenharmony_ci 	} else if ((to == NULL) && (atom->quant != XML_REGEXP_QUANT_RANGE) &&
16253aa9179Sopenharmony_ci 		   (atom->quant != XML_REGEXP_QUANT_ONCE)) {
16353aa9179Sopenharmony_ci-	    to = xmlRegNewState(ctxt);
16453aa9179Sopenharmony_ci-	    xmlRegStatePush(ctxt, to);
16553aa9179Sopenharmony_ci+	    to = xmlRegStatePush(ctxt, to);
16653aa9179Sopenharmony_ci+            if (to == NULL)
16753aa9179Sopenharmony_ci+                return(-1);
16853aa9179Sopenharmony_ci 	    ctxt->state = to;
16953aa9179Sopenharmony_ci 	    xmlFAGenerateEpsilonTransition(ctxt, atom->stop, to);
17053aa9179Sopenharmony_ci #endif
17153aa9179Sopenharmony_ci@@ -1640,8 +1647,9 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
17253aa9179Sopenharmony_ci 		if (to != NULL) {
17353aa9179Sopenharmony_ci 		    newstate = to;
17453aa9179Sopenharmony_ci 		} else {
17553aa9179Sopenharmony_ci-		    newstate = xmlRegNewState(ctxt);
17653aa9179Sopenharmony_ci-		    xmlRegStatePush(ctxt, newstate);
17753aa9179Sopenharmony_ci+		    newstate = xmlRegStatePush(ctxt);
17853aa9179Sopenharmony_ci+                    if (newstate == NULL)
17953aa9179Sopenharmony_ci+                        return(-1);
18053aa9179Sopenharmony_ci 		}
18153aa9179Sopenharmony_ci 
18253aa9179Sopenharmony_ci 		/*
18353aa9179Sopenharmony_ci@@ -1721,12 +1729,9 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
18453aa9179Sopenharmony_ci 	 * we can discard the atom and generate an epsilon transition instead
18553aa9179Sopenharmony_ci 	 */
18653aa9179Sopenharmony_ci 	if (to == NULL) {
18753aa9179Sopenharmony_ci-	    to = xmlRegNewState(ctxt);
18853aa9179Sopenharmony_ci-	    if (to != NULL)
18953aa9179Sopenharmony_ci-		xmlRegStatePush(ctxt, to);
19053aa9179Sopenharmony_ci-	    else {
19153aa9179Sopenharmony_ci+	    to = xmlRegStatePush(ctxt);
19253aa9179Sopenharmony_ci+	    if (to == NULL)
19353aa9179Sopenharmony_ci 		return(-1);
19453aa9179Sopenharmony_ci-	    }
19553aa9179Sopenharmony_ci 	}
19653aa9179Sopenharmony_ci 	xmlFAGenerateEpsilonTransition(ctxt, from, to);
19753aa9179Sopenharmony_ci 	ctxt->state = to;
19853aa9179Sopenharmony_ci@@ -1734,12 +1739,9 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
19953aa9179Sopenharmony_ci 	return(0);
20053aa9179Sopenharmony_ci     }
20153aa9179Sopenharmony_ci     if (to == NULL) {
20253aa9179Sopenharmony_ci-	to = xmlRegNewState(ctxt);
20353aa9179Sopenharmony_ci-	if (to != NULL)
20453aa9179Sopenharmony_ci-	    xmlRegStatePush(ctxt, to);
20553aa9179Sopenharmony_ci-	else {
20653aa9179Sopenharmony_ci+	to = xmlRegStatePush(ctxt);
20753aa9179Sopenharmony_ci+	if (to == NULL)
20853aa9179Sopenharmony_ci 	    return(-1);
20953aa9179Sopenharmony_ci-	}
21053aa9179Sopenharmony_ci     }
21153aa9179Sopenharmony_ci     end = to;
21253aa9179Sopenharmony_ci     if ((atom->quant == XML_REGEXP_QUANT_MULT) ||
21353aa9179Sopenharmony_ci@@ -1751,12 +1753,9 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
21453aa9179Sopenharmony_ci 	 */
21553aa9179Sopenharmony_ci         xmlRegStatePtr tmp;
21653aa9179Sopenharmony_ci 
21753aa9179Sopenharmony_ci-	tmp = xmlRegNewState(ctxt);
21853aa9179Sopenharmony_ci-	if (tmp != NULL)
21953aa9179Sopenharmony_ci-	    xmlRegStatePush(ctxt, tmp);
22053aa9179Sopenharmony_ci-	else {
22153aa9179Sopenharmony_ci+	tmp = xmlRegStatePush(ctxt);
22253aa9179Sopenharmony_ci+        if (tmp == NULL)
22353aa9179Sopenharmony_ci 	    return(-1);
22453aa9179Sopenharmony_ci-	}
22553aa9179Sopenharmony_ci 	xmlFAGenerateEpsilonTransition(ctxt, tmp, to);
22653aa9179Sopenharmony_ci 	to = tmp;
22753aa9179Sopenharmony_ci     }
22853aa9179Sopenharmony_ci@@ -5562,9 +5561,11 @@ xmlRegexpCompile(const xmlChar *regexp) {
22953aa9179Sopenharmony_ci 	return(NULL);
23053aa9179Sopenharmony_ci 
23153aa9179Sopenharmony_ci     /* initialize the parser */
23253aa9179Sopenharmony_ci+    ctxt->state = xmlRegStatePush(ctxt);
23353aa9179Sopenharmony_ci+    if (ctxt->state == NULL)
23453aa9179Sopenharmony_ci+        return(NULL);
23553aa9179Sopenharmony_ci+    ctxt->start = ctxt->state;
23653aa9179Sopenharmony_ci     ctxt->end = NULL;
23753aa9179Sopenharmony_ci-    ctxt->start = ctxt->state = xmlRegNewState(ctxt);
23853aa9179Sopenharmony_ci-    xmlRegStatePush(ctxt, ctxt->start);
23953aa9179Sopenharmony_ci 
24053aa9179Sopenharmony_ci     /* parse the expression building an automata */
24153aa9179Sopenharmony_ci     xmlFAParseRegExp(ctxt, 1);
24253aa9179Sopenharmony_ci@@ -5712,18 +5713,15 @@ xmlNewAutomata(void) {
24353aa9179Sopenharmony_ci 	return(NULL);
24453aa9179Sopenharmony_ci 
24553aa9179Sopenharmony_ci     /* initialize the parser */
24653aa9179Sopenharmony_ci-    ctxt->end = NULL;
24753aa9179Sopenharmony_ci-    ctxt->start = ctxt->state = xmlRegNewState(ctxt);
24853aa9179Sopenharmony_ci-    if (ctxt->start == NULL) {
24953aa9179Sopenharmony_ci+    ctxt->state = xmlRegStatePush(ctxt);
25053aa9179Sopenharmony_ci+    if (ctxt->state == NULL) {
25153aa9179Sopenharmony_ci 	xmlFreeAutomata(ctxt);
25253aa9179Sopenharmony_ci 	return(NULL);
25353aa9179Sopenharmony_ci     }
25453aa9179Sopenharmony_ci+    ctxt->start = ctxt->state;
25553aa9179Sopenharmony_ci+    ctxt->end = NULL;
25653aa9179Sopenharmony_ci+
25753aa9179Sopenharmony_ci     ctxt->start->type = XML_REGEXP_START_STATE;
25853aa9179Sopenharmony_ci-    if (xmlRegStatePush(ctxt, ctxt->start) < 0) {
25953aa9179Sopenharmony_ci-        xmlRegFreeState(ctxt->start);
26053aa9179Sopenharmony_ci-	xmlFreeAutomata(ctxt);
26153aa9179Sopenharmony_ci-	return(NULL);
26253aa9179Sopenharmony_ci-    }
26353aa9179Sopenharmony_ci     ctxt->flags = 0;
26453aa9179Sopenharmony_ci 
26553aa9179Sopenharmony_ci     return(ctxt);
26653aa9179Sopenharmony_ci@@ -6021,8 +6019,9 @@ xmlAutomataNewCountTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
26753aa9179Sopenharmony_ci 
26853aa9179Sopenharmony_ci     /* xmlFAGenerateTransitions(am, from, to, atom); */
26953aa9179Sopenharmony_ci     if (to == NULL) {
27053aa9179Sopenharmony_ci-        to = xmlRegNewState(am);
27153aa9179Sopenharmony_ci-	xmlRegStatePush(am, to);
27253aa9179Sopenharmony_ci+	to = xmlRegStatePush(am);
27353aa9179Sopenharmony_ci+        if (to == NULL)
27453aa9179Sopenharmony_ci+            return(NULL);
27553aa9179Sopenharmony_ci     }
27653aa9179Sopenharmony_ci     xmlRegStateAddTrans(am, from, atom, to, counter, -1);
27753aa9179Sopenharmony_ci     xmlRegAtomPush(am, atom);
27853aa9179Sopenharmony_ci@@ -6087,8 +6086,9 @@ xmlAutomataNewCountTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
27953aa9179Sopenharmony_ci 
28053aa9179Sopenharmony_ci     /* xmlFAGenerateTransitions(am, from, to, atom); */
28153aa9179Sopenharmony_ci     if (to == NULL) {
28253aa9179Sopenharmony_ci-        to = xmlRegNewState(am);
28353aa9179Sopenharmony_ci-	xmlRegStatePush(am, to);
28453aa9179Sopenharmony_ci+	to = xmlRegStatePush(am);
28553aa9179Sopenharmony_ci+        if (to == NULL)
28653aa9179Sopenharmony_ci+            return(NULL);
28753aa9179Sopenharmony_ci     }
28853aa9179Sopenharmony_ci     xmlRegStateAddTrans(am, from, atom, to, counter, -1);
28953aa9179Sopenharmony_ci     xmlRegAtomPush(am, atom);
29053aa9179Sopenharmony_ci@@ -6173,8 +6173,9 @@ xmlAutomataNewOnceTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
29153aa9179Sopenharmony_ci 
29253aa9179Sopenharmony_ci     /* xmlFAGenerateTransitions(am, from, to, atom); */
29353aa9179Sopenharmony_ci     if (to == NULL) {
29453aa9179Sopenharmony_ci-	to = xmlRegNewState(am);
29553aa9179Sopenharmony_ci-	xmlRegStatePush(am, to);
29653aa9179Sopenharmony_ci+	to = xmlRegStatePush(am);
29753aa9179Sopenharmony_ci+        if (to == NULL)
29853aa9179Sopenharmony_ci+            return(NULL);
29953aa9179Sopenharmony_ci     }
30053aa9179Sopenharmony_ci     xmlRegStateAddTrans(am, from, atom, to, counter, -1);
30153aa9179Sopenharmony_ci     xmlRegAtomPush(am, atom);
30253aa9179Sopenharmony_ci@@ -6232,8 +6233,9 @@ xmlAutomataNewOnceTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
30353aa9179Sopenharmony_ci 
30453aa9179Sopenharmony_ci     /* xmlFAGenerateTransitions(am, from, to, atom); */
30553aa9179Sopenharmony_ci     if (to == NULL) {
30653aa9179Sopenharmony_ci-	to = xmlRegNewState(am);
30753aa9179Sopenharmony_ci-	xmlRegStatePush(am, to);
30853aa9179Sopenharmony_ci+	to = xmlRegStatePush(am);
30953aa9179Sopenharmony_ci+        if (to == NULL)
31053aa9179Sopenharmony_ci+            return(NULL);
31153aa9179Sopenharmony_ci     }
31253aa9179Sopenharmony_ci     xmlRegStateAddTrans(am, from, atom, to, counter, -1);
31353aa9179Sopenharmony_ci     xmlRegAtomPush(am, atom);
31453aa9179Sopenharmony_ci@@ -6251,13 +6253,9 @@ xmlAutomataNewOnceTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
31553aa9179Sopenharmony_ci  */
31653aa9179Sopenharmony_ci xmlAutomataStatePtr
31753aa9179Sopenharmony_ci xmlAutomataNewState(xmlAutomataPtr am) {
31853aa9179Sopenharmony_ci-    xmlAutomataStatePtr to;
31953aa9179Sopenharmony_ci-
32053aa9179Sopenharmony_ci     if (am == NULL)
32153aa9179Sopenharmony_ci 	return(NULL);
32253aa9179Sopenharmony_ci-    to = xmlRegNewState(am);
32353aa9179Sopenharmony_ci-    xmlRegStatePush(am, to);
32453aa9179Sopenharmony_ci-    return(to);
32553aa9179Sopenharmony_ci+    return(xmlRegStatePush(am));
32653aa9179Sopenharmony_ci }
32753aa9179Sopenharmony_ci 
32853aa9179Sopenharmony_ci /**
32953aa9179Sopenharmony_ci-- 
33053aa9179Sopenharmony_ci2.27.0
33153aa9179Sopenharmony_ci
332