tst_QNetworkCookieJar: fix memleak

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<char[]>(...).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 <marten.nordheim@qt.io>
This commit is contained in:
Marc Mutz 2023-07-14 11:48:06 +02:00
parent e667624371
commit d3c08df330

View File

@ -14,6 +14,8 @@
#include "private/qtldurl_p.h"
#endif
#include <memory>
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<char[]>(QTest::toString(result)).get());
}
void tst_QNetworkCookieJar::cookiesForUrl_data()