Skip to content

Commit

Permalink
Check for results of List operations in addCommand #1454
Browse files Browse the repository at this point in the history
  • Loading branch information
icraggs committed Dec 16, 2024
1 parent 2793113 commit ebea1c5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/MQTTAsyncUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,11 +829,19 @@ int MQTTAsync_addCommand(MQTTAsync_queuedCommand* command, int command_size)
rc = MQTTASYNC_COMMAND_IGNORED;
}
else
ListInsert(MQTTAsync_commands, command, command_size, MQTTAsync_commands->first); /* add to the head of the list */
{
ListElement* result = ListInsert(MQTTAsync_commands, command, command_size, MQTTAsync_commands->first); /* add to the head of the list */
if (result == NULL)
rc = PAHO_MEMORY_ERROR;
}
}
else
{
ListAppend(MQTTAsync_commands, command, command_size);
if (ListAppend(MQTTAsync_commands, command, command_size) == NULL)
{
rc = PAHO_MEMORY_ERROR;
goto exit;
}
#if !defined(NO_PERSISTENCE)
if (command->client->c->persistence)
{
Expand Down

0 comments on commit ebea1c5

Please sign in to comment.