Skip to content

Commit 6fdc889

Browse files
committed
Free some memory on error eclipse-paho#882
1 parent b7db522 commit 6fdc889

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/MQTTAsync.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3785,12 +3785,15 @@ int MQTTAsync_send(MQTTAsync handle, const char* destinationName, int payloadlen
37853785
}
37863786
if ((pub->command.details.pub.destinationName = MQTTStrdup(destinationName)) == NULL)
37873787
{
3788+
free(pub);
37883789
rc = PAHO_MEMORY_ERROR;
37893790
goto exit;
37903791
}
37913792
pub->command.details.pub.payloadlen = payloadlen;
37923793
if ((pub->command.details.pub.payload = malloc(payloadlen)) == NULL)
37933794
{
3795+
free(pub->command.details.pub.destinationName);
3796+
free(pub);
37943797
rc = PAHO_MEMORY_ERROR;
37953798
goto exit;
37963799
}

0 commit comments

Comments
 (0)