mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-13 15:36:51 +01:00
Preventing memory leaks
Signed-off-by: Mariusz Suchora <mariusz.suchora@tieto.com>
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Tomoaki Yamaguchi - initial API and implementation and/or initial documentation
|
* Tomoaki Yamaguchi - initial API and implementation and/or initial documentation
|
||||||
|
* Tieto Poland Sp. z o.o. - Gateway improvements
|
||||||
**************************************************************************************/
|
**************************************************************************************/
|
||||||
|
|
||||||
#include "MQTTGWPublishHandler.h"
|
#include "MQTTGWPublishHandler.h"
|
||||||
@@ -113,6 +114,8 @@ void MQTTGWPublishHandler::handlePublish(Client* client, MQTTGWPacket* packet)
|
|||||||
{
|
{
|
||||||
replyACK(client, &pub, PUBREC);
|
replyACK(client, &pub, PUBREC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete snPacket;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Tomoaki Yamaguchi - initial API and implementation and/or initial documentation
|
* Tomoaki Yamaguchi - initial API and implementation and/or initial documentation
|
||||||
|
* Tieto Poland Sp. z o.o. - Gateway improvements
|
||||||
**************************************************************************************/
|
**************************************************************************************/
|
||||||
|
|
||||||
#include "MQTTSNGWPublishHandler.h"
|
#include "MQTTSNGWPublishHandler.h"
|
||||||
@@ -180,8 +181,6 @@ void MQTTSNPublishHandler::handlePuback(Client* client, MQTTSNPacket* packet)
|
|||||||
|
|
||||||
if ( client->isActive() )
|
if ( client->isActive() )
|
||||||
{
|
{
|
||||||
MQTTGWPacket* pubAck = new MQTTGWPacket();
|
|
||||||
|
|
||||||
if ( packet->getPUBACK(&topicId, &msgId, &rc) == 0 )
|
if ( packet->getPUBACK(&topicId, &msgId, &rc) == 0 )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -189,6 +188,7 @@ void MQTTSNPublishHandler::handlePuback(Client* client, MQTTSNPacket* packet)
|
|||||||
|
|
||||||
if ( rc == MQTTSN_RC_ACCEPTED)
|
if ( rc == MQTTSN_RC_ACCEPTED)
|
||||||
{
|
{
|
||||||
|
MQTTGWPacket* pubAck = new MQTTGWPacket();
|
||||||
pubAck->setAck(PUBACK, msgId);
|
pubAck->setAck(PUBACK, msgId);
|
||||||
Event* ev1 = new Event();
|
Event* ev1 = new Event();
|
||||||
ev1->setBrokerSendEvent(client, pubAck);
|
ev1->setBrokerSendEvent(client, pubAck);
|
||||||
@@ -226,10 +226,8 @@ void MQTTSNPublishHandler::handleRegister(Client* client, MQTTSNPacket* packet)
|
|||||||
MQTTSNString topicName;
|
MQTTSNString topicName;
|
||||||
MQTTSN_topicid topicid;
|
MQTTSN_topicid topicid;
|
||||||
|
|
||||||
|
|
||||||
if ( client->isActive() || client->isAwake())
|
if ( client->isActive() || client->isAwake())
|
||||||
{
|
{
|
||||||
MQTTSNPacket* regAck = new MQTTSNPacket();
|
|
||||||
if ( packet->getREGISTER(&id, &msgId, &topicName) == 0 )
|
if ( packet->getREGISTER(&id, &msgId, &topicName) == 0 )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -240,6 +238,8 @@ void MQTTSNPublishHandler::handleRegister(Client* client, MQTTSNPacket* packet)
|
|||||||
topicid.data.long_.name = topicName.lenstring.data;
|
topicid.data.long_.name = topicName.lenstring.data;
|
||||||
|
|
||||||
id = client->getTopics()->add(&topicid)->getTopicId();
|
id = client->getTopics()->add(&topicid)->getTopicId();
|
||||||
|
|
||||||
|
MQTTSNPacket* regAck = new MQTTSNPacket();
|
||||||
regAck->setREGACK(id, msgId, MQTTSN_RC_ACCEPTED);
|
regAck->setREGACK(id, msgId, MQTTSN_RC_ACCEPTED);
|
||||||
Event* ev = new Event();
|
Event* ev = new Event();
|
||||||
ev->setClientSendEvent(client, regAck);
|
ev->setClientSendEvent(client, regAck);
|
||||||
|
|||||||
Reference in New Issue
Block a user