From ece128fc5e6cbb5f7fe1fecf08c89f265ed8c4ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 28 Jun 2024 12:42:45 +0200 Subject: [PATCH] Http2: fix some potential constness issues The function is not const, and the access to the hash was not const, so it would check if detaching was necessary. Change-Id: Ie46cb89db20c8d9b227d50b4b6c5053dcb5791eb Reviewed-by: Mate Barany Reviewed-by: Dennis Oberst (cherry picked from commit ca735d8d4113490c54671e6a99a89c2379ea68da) Reviewed-by: Qt Cherry-pick Bot --- src/network/access/qhttp2connection.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/network/access/qhttp2connection.cpp b/src/network/access/qhttp2connection.cpp index 20dd4118617..02334e14c56 100644 --- a/src/network/access/qhttp2connection.cpp +++ b/src/network/access/qhttp2connection.cpp @@ -1136,8 +1136,8 @@ bool QHttp2Connection::readClientPreface() void QHttp2Connection::handleConnectionClosure() { const auto errorString = QCoreApplication::translate("QHttp", "Connection closed"); - for (auto it = m_streams.begin(), end = m_streams.end(); it != end; ++it) { - auto stream = it.value(); + for (auto it = m_streams.cbegin(), end = m_streams.cend(); it != end; ++it) { + const QPointer &stream = it.value(); if (stream && stream->isActive()) stream->finishWithError(PROTOCOL_ERROR, errorString); } @@ -1703,7 +1703,7 @@ void QHttp2Connection::handleWINDOW_UPDATE() if (!valid || qAddOverflow(sessionSendWindowSize, qint32(delta), &sum)) return connectionError(PROTOCOL_ERROR, "WINDOW_UPDATE invalid delta"); sessionSendWindowSize = sum; - for (auto &stream : m_streams) { + for (const auto &stream : std::as_const(m_streams)) { if (!stream || !stream->isActive()) continue; // Stream may have been unblocked, so maybe try to write again