Correct freeing of some persistence buffers

This commit is contained in:
Ian Craggs 2022-02-10 18:09:15 +00:00
parent 932cfbb62c
commit 4b1389e6d8
2 changed files with 6 additions and 5 deletions

View File

@ -662,14 +662,14 @@ int MQTTAsync_restoreCommands(MQTTAsyncs* client)
cmd->seqno = atoi(strchr(msgkeys[i], '-')+1); /* key format is tag'-'seqno */
/* we can just append the commands to the list as they've already been sorted */
ListAppend(MQTTAsync_commands, cmd, sizeof(MQTTAsync_queuedCommand));
if (buffer)
free(buffer);
client->command_seqno = max(client->command_seqno, cmd->seqno);
commands_restored++;
if (cmd->command.type == PUBLISH)
client->noBufferedMessages++;
}
}
if (buffer)
free(buffer);
if (msgkeys[i])
free(msgkeys[i]);
i++;
@ -1246,11 +1246,11 @@ static int MQTTAsync_processCommand(void)
free(command->key);
command->key = NULL;
command = MQTTAsync_restoreCommand(buffer, buflen, MQTTVersion, command);
if (buffer)
free(buffer);
}
else
Log(LOG_ERROR, -1, "Error restoring command: rc %d from pget\n", rc);
if (buffer)
free(buffer);
}
MQTTAsync_unpersistCommand(command);
}

View File

@ -886,10 +886,11 @@ int MQTTPersistence_restoreMessageQueue(Clients* c)
{
qe->seqno = atoi(strchr(msgkeys[i], '-')+1); /* key format is tag'-'seqno */
MQTTPersistence_insertInSeqOrder(c->messageQueue, qe, sizeof(MQTTPersistence_qEntry));
free(buffer);
c->qentry_seqno = max(c->qentry_seqno, qe->seqno);
entries_restored++;
}
if (buffer)
free(buffer);
}
if (msgkeys[i])
{