diff options
author | Jarek Kobus <jaroslaw.kobus@theqtcompany.com> | 2016-05-02 14:24:27 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@theqtcompany.com> | 2016-05-02 12:41:40 +0000 |
commit | 91cdd717d613fc211ba4565b0171a149e5ac354d (patch) | |
tree | ea39ede91c820e279f94fe99396f57098746e2dd | |
parent | 1838e854828eb01512d4776cdc54887b7cf9c33b (diff) |
Don't leak m_doc->root when nested <scxml> occurred.
Change-Id: I77463e007bc2d4c1ece6c4341026968e6fe10793
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | src/scxml/qscxmlparser.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qscxmlc/data/nestedScxml.scxml | 7 | ||||
-rw-r--r-- | tests/auto/qscxmlc/tst_qscxmlc.qrc | 1 |
3 files changed, 10 insertions, 2 deletions
diff --git a/src/scxml/qscxmlparser.cpp b/src/scxml/qscxmlparser.cpp index 2efd203..312b5ed 100644 --- a/src/scxml/qscxmlparser.cpp +++ b/src/scxml/qscxmlparser.cpp @@ -2216,14 +2216,14 @@ void QScxmlParserPrivate::parse() return; if (elKind == ParserState::Scxml) { - m_doc->root = new DocumentModel::Scxml(xmlLocation()); - auto scxml = m_doc->root; if (m_state != QScxmlParser::StartingParsing || !m_stack.isEmpty()) { addError(xmlLocation(), QStringLiteral("found scxml tag mid stream")); return; } else { m_state = QScxmlParser::ParsingScxml; } + m_doc->root = new DocumentModel::Scxml(xmlLocation()); + auto scxml = m_doc->root; if (m_reader->namespaceUri() != scxmlNamespace) { addError(QStringLiteral("default namespace must be set with xmlns=\"%1\" in the scxml tag").arg(scxmlNamespace)); return; diff --git a/tests/auto/qscxmlc/data/nestedScxml.scxml b/tests/auto/qscxmlc/data/nestedScxml.scxml new file mode 100644 index 0000000..2f96347 --- /dev/null +++ b/tests/auto/qscxmlc/data/nestedScxml.scxml @@ -0,0 +1,7 @@ +<?xml version="1.0" ?> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + datamodel="ecmascript" name="StateMachine"> + <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + datamodel="ecmascript" name="NestedStateMachine"> + </scxml> +</scxml> diff --git a/tests/auto/qscxmlc/tst_qscxmlc.qrc b/tests/auto/qscxmlc/tst_qscxmlc.qrc index e6f9e37..d6b8a6a 100644 --- a/tests/auto/qscxmlc/tst_qscxmlc.qrc +++ b/tests/auto/qscxmlc/tst_qscxmlc.qrc @@ -37,5 +37,6 @@ <file>data/noContentInInvoke4.scxml</file> <file>data/prematureEndOfDocument2.scxml</file> <file>data/wrongRoot.scxml</file> + <file>data/nestedScxml.scxml</file> </qresource> </RCC> |