summaryrefslogtreecommitdiffstats
path: root/src/xml/dom
diff options
context:
space:
mode:
authorSami Rosendahl <ext-sami.1.rosendahl@nokia.com>2012-01-18 08:50:44 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-01-18 17:07:00 (GMT)
commitd3145bf9c72951e08e3d574c3bdc7bdf435c8281 (patch)
tree3fc7b51471a0b5cf88622d4d0f9b9e6bae7b04bf /src/xml/dom
parentd8d4dc8599fb251ca201f5c3f496df1045d288c3 (diff)
downloadQt-d3145bf9c72951e08e3d574c3bdc7bdf435c8281.zip
Qt-d3145bf9c72951e08e3d574c3bdc7bdf435c8281.tar.gz
Qt-d3145bf9c72951e08e3d574c3bdc7bdf435c8281.tar.bz2
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/dom')
-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 60e976b..8bd41a7 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));