From 4178aab79a32b7dcc0332c352e40a2e7ff6c3482 Mon Sep 17 00:00:00 2001 From: alex cg Date: Mon, 6 Nov 2023 21:59:06 +0100 Subject: [PATCH] Issue8: added deleted PublishMessage un PublishMessageAction to avoid memory leak --- src/Actions/PublishAction.cpp | 5 +++++ src/MqttBroker/MqttBroker.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Actions/PublishAction.cpp b/src/Actions/PublishAction.cpp index f7abade..4bfdacd 100644 --- a/src/Actions/PublishAction.cpp +++ b/src/Actions/PublishAction.cpp @@ -4,6 +4,11 @@ PublishAction::PublishAction(MqttClient* mqttClient, ReaderMqttPacket packetRead publishMqttMessage = new PublishMqttMessage(packetReaded); } +PublishAction::~PublishAction(){ + delete publishMqttMessage; +} + + void PublishAction::doAction(){ mqttClient->notifyPublishRecived(publishMqttMessage); } \ No newline at end of file diff --git a/src/MqttBroker/MqttBroker.h b/src/MqttBroker/MqttBroker.h index 39ed75c..d1938bb 100644 --- a/src/MqttBroker/MqttBroker.h +++ b/src/MqttBroker/MqttBroker.h @@ -418,7 +418,7 @@ class PublishAction: public Action{ * PublishMqttMessage object. */ PublishAction(MqttClient* mqttClient, ReaderMqttPacket packetReaded); - + ~PublishAction(); /** * @brief Notify to Broker class a publish mqtt request * recevided from this client.