From 3ffd32da0d40a4bb819a653c974dc492f6c1201a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 10 Oct 2023 15:45:14 +0200 Subject: [PATCH] Http: don't try to send request on a closed socket We have code in the protocolHandlers that tries to handle this case, but if we have an error before we create protocolHandler (read: proxy complains about something) we will assert in debug, or deref nullptr in release. Pick-to: 6.2 Change-Id: I4bde9c8af0fa96dc11f77ca4d4b5cb84c31b54fa Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov (cherry picked from commit 5c7c44cf8390cb08f3b46c9763c2d11da7179c93) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 5632626375c0de4fd1f54318b065d9dfb9f79831) --- src/network/access/qhttpnetworkconnection.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index f183a6b7191..ec877ff79ed 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -1043,6 +1043,11 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest() //resend the necessary ones. for (int i = 0; i < activeChannelCount; ++i) { if (channels[i].resendCurrent && (channels[i].state != QHttpNetworkConnectionChannel::ClosingState)) { + if (!channels[i].socket + || channels[i].socket->state() == QAbstractSocket::UnconnectedState) { + if (!channels[i].ensureConnection()) + continue; + } channels[i].resendCurrent = false; // if this is not possible, error will be emitted and connection terminated