diff --git a/Sming/SmingCore/Network/MqttClient.cpp b/Sming/SmingCore/Network/MqttClient.cpp index ae213e8496..ccc7550902 100644 --- a/Sming/SmingCore/Network/MqttClient.cpp +++ b/Sming/SmingCore/Network/MqttClient.cpp @@ -59,15 +59,9 @@ MqttClient::MqttClient(bool withDefaultPayloadParser /* = true */, bool autoDest MqttClient::~MqttClient() { - mqtt_message_t* message = nullptr; - do { - message = requestQueue.dequeue(); - if(message) { - break; - } - - mqtt_message_clear(message, 1); - } while(true); + while(requestQueue.count() != 0) { + mqtt_message_clear(requestQueue.dequeue(), 1); + } mqtt_message_clear(&connectMessage, 0); if(outgoingMessage) {