summaryrefslogtreecommitdiffstats
path: root/tests/auto/qdom
diff options
context:
space:
mode:
authorSami Rosendahl <ext-sami.1.rosendahl@nokia.com>2012-01-16 14:31:33 +0200
committerQt by Nokia <qt-info@nokia.com>2012-01-18 18:07:00 +0100
commitfb38e3801724471a9fb0ea3b412e631223250c44 (patch)
treec78635a7344824809bcf7552df03750ddee168e3 /tests/auto/qdom
parent3e4fa9abefc5e6ede2c47d22e6aca3f38183d4a0 (diff)
Fix memory leak in QDomDocument DTD notation declaration handler
The created notation node's reference count needs to be decremented to 0 before it is added as a child, because appendChild will increment the reference count to correct value of 1. Also added autotest DTDNotationDecl to tst_qdom to expose the leak when executed under valgrind memcheck. There was no previous test coverage for the notation declarations in DTD. Task-number: QTBUG-22588 Change-Id: I452d45cb70dfcda48061e0d4af5085ab1c1ad59e (From Qt5 commit 1bc31fa43ddefe468c9f079156bfad0371e2a61b) Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/qdom')
-rw-r--r--tests/auto/qdom/tst_qdom.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp
index 32eff9d03d..3ba75e30be 100644
--- a/tests/auto/qdom/tst_qdom.cpp
+++ b/tests/auto/qdom/tst_qdom.cpp
@@ -132,6 +132,7 @@ private slots:
void taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() const;
void cloneDTD_QTBUG8398() const;
+ void DTDNotationDecl();
void cleanupTestCase() const;
@@ -1930,5 +1931,28 @@ void tst_QDom::cloneDTD_QTBUG8398() const
domDocument2.save(stream, 0);
QCOMPARE(output, expected);
}
+
+void tst_QDom::DTDNotationDecl()
+{
+ QString dtd("<?xml version='1.0' encoding='UTF-8'?>\n"
+ "<!DOCTYPE first [\n"
+ "<!NOTATION gif SYSTEM 'image/gif'>\n"
+ "<!NOTATION jpeg SYSTEM 'image/jpeg'>\n"
+ "]>\n"
+ "<first/>\n");
+
+ QDomDocument domDocument;
+ QVERIFY(domDocument.setContent(dtd));
+
+ const QDomDocumentType doctype = domDocument.doctype();
+ QCOMPARE(doctype.notations().size(), 2);
+
+ QVERIFY(doctype.namedItem(QString("gif")).isNotation());
+ QCOMPARE(doctype.namedItem(QString("gif")).toNotation().systemId(), QString("image/gif"));
+
+ QVERIFY(doctype.namedItem(QString("jpeg")).isNotation());
+ QCOMPARE(doctype.namedItem(QString("jpeg")).toNotation().systemId(), QString("image/jpeg"));
+}
+
QTEST_MAIN(tst_QDom)
#include "tst_qdom.moc"