diff --git a/src/TinyMqtt.cpp b/src/TinyMqtt.cpp index f9c6600..e2f7a2d 100644 --- a/src/TinyMqtt.cpp +++ b/src/TinyMqtt.cpp @@ -34,6 +34,7 @@ MqttClient::MqttClient(MqttBroker* parent) MqttClient::~MqttClient() { close(); + delete client; parent->removeClient(this); } @@ -42,8 +43,6 @@ void MqttClient::close() if (client) { client->stop(); - delete client; - client = nullptr; } }