summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkreplyhttpimpl.cpp
diff options
context:
space:
mode:
authorVladimir Belyavsky <belyavskyv@gmail.com>2023-09-06 12:49:45 +0300
committerVladimir Belyavsky <belyavskyv@gmail.com>2023-09-06 18:19:12 +0000
commit74fb2519e32760dbe9f10a9ffd2b460d827062a5 (patch)
treee56cac04f449cc47de14d5711a63be26798e21ab /src/network/access/qnetworkreplyhttpimpl.cpp
parentac9e9687559df28dbd6bc9bb645006ff454e18bd (diff)
QNetworkReply: fix potential nullptr access in loadFromCacheIfAllowed()
Fix a potential nullptr access in QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed() on accessing to QAbstractNetworkCache::data(). It is not yet clear in what cases cached data can be null, especially if metaData is present, but we have user reports of such crashes. Amends a6776de0c70d23ac197682c7bef603450cb8b03f Fixes: QTBUG-116788 Pick-to: 6.2 6.5 6.6 Change-Id: I548065c6f809d9d45db6dd785c28acbdc77621e2 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network/access/qnetworkreplyhttpimpl.cpp')
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index 33065b1b88..900476e7c3 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -509,7 +509,8 @@ bool QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(QHttpNetworkRequest &h
it = cacheHeaders.findRawHeader("content-length");
if (it != cacheHeaders.rawHeaders.constEnd()) {
- if (nc->data(httpRequest.url())->size() < it->second.toLongLong())
+ QIODevice *data = nc->data(httpRequest.url());
+ if (!data || data->size() < it->second.toLongLong())
return false; // The data is smaller than the content-length specified
}