Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix thoretical possible memory leaks related to topic in error case #1521

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/MQTTAsyncUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2320,6 +2320,10 @@ thread_return_type WINAPI MQTTAsync_receiveThread(void* n)
m->c->connected = 0; /* don't send disconnect packet back */
nextOrClose(m, discrc, "Received disconnect");
}
else
{
Log(LOG_ERROR, -1, "Unexpected packet type %d", pack->header.bits.type);
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/MQTTPacket.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ void* MQTTPacket_publish(int MQTTVersion, unsigned char aHeader, char* data, siz
{
if (enddata - curdata < 2) /* Is there enough data for the msgid? */
{
free(pack->topic);
pack->topic = NULL;
free(pack);
pack = NULL;
goto exit;
Expand All @@ -589,6 +591,8 @@ void* MQTTPacket_publish(int MQTTVersion, unsigned char aHeader, char* data, siz
pack->properties = props;
if (MQTTProperties_read(&pack->properties, &curdata, enddata) != 1)
{
free(pack->topic);
pack->topic = NULL;
if (pack->properties.array)
free(pack->properties.array);
if (pack)
Expand Down
Loading