From c94175ff43ec7475e71c1a76fb4d4024b08ddac0 Mon Sep 17 00:00:00 2001 From: Tatiana Borisova Date: Wed, 19 Aug 2026 19:43:03 +0200 Subject: [PATCH] Stop parsing after closeConnection() - Parsing continued after closeConnection(), leaving the client in the "connected" state with a dead socket. This led to a permanent, unrecoverable wedge in Release builds and a crash in Debug builds. - Check whether the client is already disconnected before changing its state to BrokerConnected. Pick-to: 6.11 6.12 6.8 Task-number: QTBUG-149565 Change-Id: I13d45c24d24fe862d9aec6a7e421f5ef4d494db0 Reviewed-by: Ivan Solovev --- src/mqtt/qmqttconnection.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mqtt/qmqttconnection.cpp b/src/mqtt/qmqttconnection.cpp index 56cd823..5138d97 100644 --- a/src/mqtt/qmqttconnection.cpp +++ b/src/mqtt/qmqttconnection.cpp @@ -1567,6 +1567,10 @@ void QMqttConnection::finalize_connack() // MQTT 5.0 has variable part != 2 in the header if (m_clientPrivate->m_protocolVersion == QMqttClient::MQTT_5_0) { readConnackProperties(m_clientPrivate->m_serverConnectionProperties); + // readConnackProperties() might have closed the connection due to a malformed + // property length. Do not overwrite the state of a connection which is gone. + if (m_internalState == BrokerDisconnected) + return; m_receiveAliases.resize(m_clientPrivate->m_serverConnectionProperties.maximumTopicAlias()); m_publishAliases.resize(m_clientPrivate->m_connectionProperties.maximumTopicAlias());