From d3c08df330f615dc3a248fd0c346a5c1ad6e1c38 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 14 Jul 2023 11:48:06 +0200 Subject: [PATCH] tst_QNetworkCookieJar: fix memleak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QTest::toString() returns a new[]'ed char array, which needs to be manually deleted and QVERIFY2() doesn't take ownership of its second argument. Fix by wrapping in unique_ptr(...).get(). Bug exists since the dawn of the public history. Pick-to: 6.6 6.5 6.2 5.15 Change-Id: I19ec09f46ec0ce5eacf1437f62dc625bc9343831 Reviewed-by: MÃ¥rten Nordheim --- .../access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index 72096ceee5..ac07a0212a 100644 --- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -14,6 +14,8 @@ #include "private/qtldurl_p.h" #endif +#include + class tst_QNetworkCookieJar: public QObject { Q_OBJECT @@ -249,7 +251,7 @@ void tst_QNetworkCookieJar::setCookiesFromUrl() QVERIFY2(result.contains(cookie), cookie.toRawForm()); result.removeAll(cookie); } - QVERIFY2(result.isEmpty(), QTest::toString(result)); + QVERIFY2(result.isEmpty(), std::unique_ptr(QTest::toString(result)).get()); } void tst_QNetworkCookieJar::cookiesForUrl_data()