Fix memory leak in qSetMessagePattern

We were leaking memory in case setPattern was called multiple
times

Task-number: QTBUG-43893
Change-Id: Icd9c214edea064aeaeb6f92a9c62836238ccd344
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Kai Koehne 2015-01-26 15:21:12 +01:00 committed by Jani Heikkinen
parent 8e0f56280a
commit 5f6bbce4be

View File

@ -866,7 +866,7 @@ QMessagePattern::QMessagePattern()
QMessagePattern::~QMessagePattern()
{
for (int i = 0; literals[i] != 0; ++i)
for (int i = 0; literals[i]; ++i)
delete [] literals[i];
delete [] literals;
literals = 0;
@ -876,8 +876,12 @@ QMessagePattern::~QMessagePattern()
void QMessagePattern::setPattern(const QString &pattern)
{
if (literals) {
for (int i = 0; literals[i]; ++i)
delete [] literals[i];
delete [] literals;
}
delete [] tokens;
delete [] literals;
// scanner
QList<QString> lexemes;