From 254f35ce98bebd8f4446fec66bb50f2126b61c28 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 5 Apr 2017 15:35:38 +0200 Subject: [PATCH] QNetworkReplyHttpImpl - check 'isOpen' twice A signal emitted after the first 'isOpen' check on QNetworkReply can trigger a slot that aborts/closes our reply. So before we can append any data to reply's buffer, we have to re-check that we're still open. Task-number: QTBUG-59909 Change-Id: I781d5a4fd5fc30d485af63f45cf36c254378af64 Reviewed-by: Edward Welbourne Reviewed-by: Alex Trotsenko Reviewed-by: Timur Pocheptsov --- src/network/access/qnetworkreplyhttpimpl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index bdb23ede1d..fec3b0a100 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -1883,6 +1883,12 @@ void QNetworkReplyHttpImplPrivate::_q_cacheLoadReadyRead() totalSize.isNull() ? Q_INT64_C(-1) : totalSize.toLongLong()); } } + + // A signal we've emitted might be handled by a slot that aborts, + // so we need to check for that and bail out if it's happened: + if (!q->isOpen()) + return; + // If there are still bytes available in the cacheLoadDevice then the user did not read // in response to the readyRead() signal. This means we have to load from the cacheLoadDevice // and buffer that stuff. This is needed to be able to properly emit finished() later.