summaryrefslogtreecommitdiffstats
path: root/src/xml
diff options
context:
space:
mode:
authorSami Rosendahl <ext-sami.1.rosendahl@nokia.com>2012-01-18 10:50:44 +0200
committerQt by Nokia <qt-info@nokia.com>2012-01-18 18:07:00 +0100
commitd3145bf9c72951e08e3d574c3bdc7bdf435c8281 (patch)
tree3fc7b51471a0b5cf88622d4d0f9b9e6bae7b04bf /src/xml
parentd8d4dc8599fb251ca201f5c3f496df1045d288c3 (diff)
Fix memory leak in QDomDocument entity text expansion
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. Re-enabled commented-out test data of tst_QDom::setContent to exercise the code path with the leak. Change-Id: I8193699779b688fd818439d6ef9f850b3373dcc3 (from Qt5 commit b6a43cfe9c136e298feaa8d48fc252fdb3d4e7c5) Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/xml')
-rw-r--r--src/xml/dom/qdom.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index 60e976be3f..8bd41a72ea 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -7461,6 +7461,7 @@ bool QDomHandler::characters(const QString& ch)
QScopedPointer<QDomEntityPrivate> e(new QDomEntityPrivate(doc, 0, entityName,
QString(), QString(), QString()));
e->value = ch;
+ e->ref.deref();
doc->doctype()->appendChild(e.data());
e.take();
n.reset(doc->createEntityReference(entityName));