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 tst_QDom::setContent to exercise the code path with the leak. Change-Id: Ieb015d68ba9bbb3f20dd47e76835ad15abb1738e Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
acdd5fecb7
commit
b6a43cfe9c
@ -7457,6 +7457,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));
|
||||
|
@ -168,7 +168,7 @@ void tst_QDom::setContent_data()
|
||||
QTest::addColumn<QStringList>("featuresFalse");
|
||||
QTest::addColumn<QString>("res");
|
||||
|
||||
/* QTest::newRow( "01" ) << doc01
|
||||
QTest::newRow( "01" ) << doc01
|
||||
<< QStringList()
|
||||
<< QString("http://trolltech.com/xml/features/report-whitespace-only-CharData").split(' ')
|
||||
<< QString("<!DOCTYPE a1>\n"
|
||||
@ -240,7 +240,7 @@ void tst_QDom::setContent_data()
|
||||
" </b3>\n"
|
||||
"</a1>\n");
|
||||
|
||||
*/ QTest::newRow("05") << QString("<message>\n"
|
||||
QTest::newRow("05") << QString("<message>\n"
|
||||
" <body><b>foo</b>>]]></body>\n"
|
||||
"</message>\n")
|
||||
<< QStringList() << QStringList()
|
||||
|
Loading…
Reference in New Issue
Block a user