From 6039179373f7552c2a711b06a7d69b9ca9d2b175 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20Str=C3=B8mme?= Date: Tue, 16 Oct 2012 11:34:00 +0200 Subject: [PATCH] Fix for memory leak in ResultStore MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit In ResultStoreBase::addResults() it possible that the ResultItem we create is invalid (filter-mode enabled). Since an invalid ResultItem won't have any result data, we need to make sure that we don't allocate any data for it. Task-number: QTBUG-27224 Change-Id: Ic99b191db0e9dd4e29b64911f87d90a8148bb7a5 Reviewed-by: Morten Johan Sørvig --- src/corelib/thread/qresultstore.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/thread/qresultstore.h b/src/corelib/thread/qresultstore.h index 3314cd7..d084e24 100644 --- a/src/corelib/thread/qresultstore.h +++ b/src/corelib/thread/qresultstore.h @@ -176,7 +176,10 @@ public: int addResults(int index, const QVector *results, int totalCount) { - return ResultStoreBase::addResults(index, new QVector(*results), results->count(), totalCount); + if (m_filterMode == true && results->count() != totalCount && 0 == results->count()) + return ResultStoreBase::addResults(index, 0, 0, totalCount); + else + return ResultStoreBase::addResults(index, new QVector(*results), results->count(), totalCount); } int addCanceledResult(int index) -- 2.7.4