From e4b19bfb94630c7da37d150955ccc246498966cf Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 14 Jan 2017 15:04:34 +0100 Subject: [PATCH] Plug memleaks in tst_QHeaderView The char* returned from QTest::toString() calls must be manually delete[]ed. Change-Id: Iad078e8741e3e97693b1a417693f414b3fb3ec09 Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- .../auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 1078dcc2e9..7bfec2831d 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -2523,7 +2523,8 @@ void tst_QHeaderView::calculateAndCheck(int cppline, const int precalced_compare const bool sanity_checks = true; if (sanity_checks) { QString msg = QString("sanity problem at ") + sline; - char *verifytext = QTest::toString(msg); + const QScopedArrayPointer holder(QTest::toString(msg)); + const auto verifytext = holder.data(); QVERIFY2(m_tableview->model()->rowCount() == view->count() , verifytext); QVERIFY2(view->visualIndex(lastindex + 1) <= 0, verifytext); // there is no such index in model @@ -2555,7 +2556,8 @@ void tst_QHeaderView::calculateAndCheck(int cppline, const int precalced_compare msg += istr(chk_visual) + istr(chk_logical) + istr(chk_sizes) + istr(chk_hidden_size) + istr(chk_lookup_visual) + istr(chk_lookup_logical) + istr(header_lenght, false) + "};"; - char *verifytext = QTest::toString(msg); + const QScopedArrayPointer holder(QTest::toString(msg)); + const auto verifytext = holder.data(); QVERIFY2(chk_visual == x[0], verifytext); QVERIFY2(chk_logical == x[1], verifytext);