Plug leaks in tst_QXmlSimpleReader

The QXmlInputSource objects were allocated on the heap,
but never deleted.

Fix by allocating them on the stack instead.

Change-Id: Ifd8bd41d778c0634b7a426bbd22a367dfce511c9
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
bb10
Marc Mutz 2016-10-09 19:29:25 +02:00
parent 940ea856f0
commit 6d6074e04f
1 changed files with 6 additions and 6 deletions

View File

@ -765,22 +765,22 @@ void tst_QXmlSimpleReader::dtdRecursionLimit()
QVERIFY(file.open(QIODevice::ReadOnly));
QXmlSimpleReader xmlReader;
{
QXmlInputSource *source = new QXmlInputSource(&file);
QXmlInputSource source(&file);
TestHandler handler;
xmlReader.setDeclHandler(&handler);
xmlReader.setErrorHandler(&handler);
QVERIFY(!xmlReader.parse(source));
QVERIFY(!xmlReader.parse(&source));
}
file.close();
file.setFileName("xmldocs/1-levels-nested-dtd.xml");
QVERIFY(file.open(QIODevice::ReadOnly));
{
QXmlInputSource *source = new QXmlInputSource(&file);
QXmlInputSource source(&file);
TestHandler handler;
xmlReader.setDeclHandler(&handler);
xmlReader.setErrorHandler(&handler);
QVERIFY(!xmlReader.parse(source));
QVERIFY(!xmlReader.parse(&source));
// The error wasn't because of the recursion limit being reached,
// it was because the document is not valid.
QVERIFY(handler.recursionCount < 2);
@ -790,11 +790,11 @@ void tst_QXmlSimpleReader::dtdRecursionLimit()
file.setFileName("xmldocs/internal-entity-polynomial-attribute.xml");
QVERIFY(file.open(QIODevice::ReadOnly));
{
QXmlInputSource *source = new QXmlInputSource(&file);
QXmlInputSource source(&file);
TestHandler handler;
xmlReader.setDeclHandler(&handler);
xmlReader.setErrorHandler(&handler);
QVERIFY(!xmlReader.parse(source));
QVERIFY(!xmlReader.parse(&source));
QCOMPARE(handler.recursionCount, 2);
}
}