Fixed memory leak in QXmlStreamReader

Fixed memory leak caused by repetitive usage of the same
QXmlStreamReader instance.

Task-number: QTBUG-27889
Change-Id: I673f4d26bae1503cb43e972f95b418dbf6d6fd89
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
This commit is contained in:
Roman Pasechnik 2013-02-18 16:08:28 +02:00 committed by The Qt Project
parent f9497b1a54
commit 342c99ff45
2 changed files with 3 additions and 0 deletions

View File

@ -784,6 +784,7 @@ QXmlStreamPrivateTagStack::QXmlStreamPrivateTagStack()
NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
namespaceDeclaration.prefix = addToStringStorage(QLatin1String("xml"));
namespaceDeclaration.namespaceUri = addToStringStorage(QLatin1String("http://www.w3.org/XML/1998/namespace"));
initialTagStackStringStorageSize = tagStackStringStorageSize;
}
#ifndef QT_NO_XMLSTREAMREADER
@ -854,6 +855,7 @@ void QXmlStreamReaderPrivate::init()
rawReadBuffer.clear();
dataBuffer.clear();
readBuffer.clear();
tagStackStringStorageSize = initialTagStackStringStorageSize;
type = QXmlStreamReader::NoToken;
error = QXmlStreamReader::NoError;

View File

@ -697,6 +697,7 @@ public:
QXmlStreamSimpleStack<NamespaceDeclaration> namespaceDeclarations;
QString tagStackStringStorage;
int tagStackStringStorageSize;
int initialTagStackStringStorageSize;
bool tagsDone;
inline QStringRef addToStringStorage(const QStringRef &s) {