1
0
mirror of https://github.com/qt/qtmqtt.git synced 2026-10-25 16:16:26 +00:00

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 <ivan.solovev@qt.io>
This commit is contained in:
Tatiana Borisova 2026-08-19 19:43:03 +02:00
parent 13288574c1
commit c94175ff43

View File

@ -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());