diff --git a/mqttpacket.cpp b/mqttpacket.cpp index dcefcdf..0c424ab 100644 --- a/mqttpacket.cpp +++ b/mqttpacket.cpp @@ -801,10 +801,10 @@ void MqttPacket::handleDisconnect() if (this->protocolVersion >= ProtocolVersion::Mqtt5) { - reasonCode = static_cast(readByte()); - if (!atEnd()) { + reasonCode = static_cast(readByte()); + const size_t proplen = decodeVariableByteIntAtPos(); const size_t prop_end_at = pos + proplen;