http: fix leakage of network cache qiodevice

The QIODevice is owned by the caller of data(), so we should have
freed it.

Amends a6776de0c7

Fixes: QTBUG-117787
Pick-to: 6.6 6.5 6.2
Change-Id: Ic5575649038480f52cc13ee229980ee1c7cee728
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
This commit is contained in:
Mårten Nordheim 2023-10-04 14:36:16 +02:00
parent d9370d0962
commit 23996976cf

View File

@ -510,7 +510,7 @@ bool QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(QHttpNetworkRequest &h
it = cacheHeaders.findRawHeader("content-length");
if (it != cacheHeaders.rawHeaders.constEnd()) {
QIODevice *data = nc->data(httpRequest.url());
std::unique_ptr<QIODevice> data(nc->data(httpRequest.url()));
if (!data || data->size() < it->second.toLongLong())
return false; // The data is smaller than the content-length specified
}