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.6 6.5 6.2
Change-Id: I4bde9c8af0fa96dc11f77ca4d4b5cb84c31b54fa
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
bb10
Mårten Nordheim 2023-10-10 15:45:14 +02:00
parent 9e93781b9c
commit 5c7c44cf83
1 changed files with 5 additions and 0 deletions

View File

@ -1046,6 +1046,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