summaryrefslogtreecommitdiffstats
path: root/src/xml
diff options
context:
space:
mode:
authorSami Rosendahl <ext-sami.1.rosendahl@nokia.com>2012-01-16 12:31:33 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-01-18 17:07:00 (GMT)
commitfb38e3801724471a9fb0ea3b412e631223250c44 (patch)
treec78635a7344824809bcf7552df03750ddee168e3 /src/xml
parent3e4fa9abefc5e6ede2c47d22e6aca3f38183d4a0 (diff)
downloadQt-fb38e3801724471a9fb0ea3b412e631223250c44.zip
Qt-fb38e3801724471a9fb0ea3b412e631223250c44.tar.gz
Qt-fb38e3801724471a9fb0ea3b412e631223250c44.tar.bz2
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 'src/xml')
-rw-r--r--src/xml/dom/qdom.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index fc3df05..85b89de 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -7557,6 +7557,8 @@ bool QDomHandler::externalEntityDecl(const QString &name, const QString &publicI
bool QDomHandler::notationDecl(const QString & name, const QString & publicId, const QString & systemId)
{
QDomNotationPrivate* n = new QDomNotationPrivate(doc, 0, name, publicId, systemId);
+ // keep the refcount balanced: appendChild() does a ref anyway.
+ n->ref.deref();
doc->doctype()->appendChild(n);
return true;
}