diff options
author | Sami Rosendahl <ext-sami.1.rosendahl@nokia.com> | 2011-10-19 07:36:24 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-18 17:07:00 (GMT) |
commit | d8d4dc8599fb251ca201f5c3f496df1045d288c3 (patch) | |
tree | 26ce5f2a4d7b0ad7604e4fd8d69cd01a1990e795 /src/xml/dom/qdom.cpp | |
parent | fb38e3801724471a9fb0ea3b412e631223250c44 (diff) | |
download | Qt-d8d4dc8599fb251ca201f5c3f496df1045d288c3.zip Qt-d8d4dc8599fb251ca201f5c3f496df1045d288c3.tar.gz Qt-d8d4dc8599fb251ca201f5c3f496df1045d288c3.tar.bz2 |
Fix memory leak in QDomDocument DTD entity declaration handler
The created entity 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 DTDEntityDecl to tst_qdom to expose the leak when
executed under valgrind memcheck. There was no previous direct test case for unparsed
entity declarations in DTD, only indirect coverage via regression test
cloneDTD_QTBUG8398.
Task-number: QTBUG-22587
Change-Id: I2c3a78569b564b80ff5e2f63f59fa36c94a22236
(From Qt5 commit d55cdcd59fdddd660193ddff40fbd52bef57c0c9)
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/xml/dom/qdom.cpp')
-rw-r--r-- | src/xml/dom/qdom.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 85b89de..60e976b 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -7545,6 +7545,8 @@ bool QDomHandler::unparsedEntityDecl(const QString &name, const QString &publicI { QDomEntityPrivate* e = new QDomEntityPrivate(doc, 0, name, publicId, systemId, notationName); + // keep the refcount balanced: appendChild() does a ref anyway. + e->ref.deref(); doc->doctype()->appendChild(e); return true; } |