From b20d6cded7be8b86bed93ee705420bfb01700c5b Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Thu, 29 Oct 2015 09:43:33 +0200 Subject: Fix QDomNamedNodeMap::item crash with negative index Task-number: QTBUG-49113 Change-Id: I62dee4c112b73a25628657bc3d2ae675f26b87d8 Reviewed-by: David Faure --- tests/auto/xml/dom/qdom/tst_qdom.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/auto/xml/dom/qdom/tst_qdom.cpp') diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index a4a3f1f6b3..04cd0b300f 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -119,6 +119,7 @@ private slots: void cloneDTD_QTBUG8398() const; void DTDNotationDecl(); void DTDEntityDecl(); + void QTBUG49113_dontCrashWithNegativeIndex() const; void cleanupTestCase() const; @@ -1979,5 +1980,13 @@ void tst_QDom::DTDEntityDecl() QCOMPARE(doctype.namedItem(QString("logo")).toEntity().notationName(), QString("gif")); } +void tst_QDom::QTBUG49113_dontCrashWithNegativeIndex() const +{ + QDomDocument doc; + QDomElement elem = doc.appendChild(doc.createElement("root")).toElement(); + QDomNode node = elem.attributes().item(-1); + QVERIFY(node.isNull()); +} + QTEST_MAIN(tst_QDom) #include "tst_qdom.moc" -- cgit v1.2.3