Merge pull request #383 from LeoonLee/master

fixd: when restore command, "topics" no malloc.
This commit is contained in:
Ian Craggs 2017-12-15 10:46:54 +00:00 committed by GitHub
commit 6aa07f575b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -718,6 +718,12 @@ static MQTTAsync_queuedCommand* MQTTAsync_restoreCommand(char* buffer, int bufle
case SUBSCRIBE:
command->details.sub.count = *(int*)ptr;
ptr += sizeof(int);
if (command->details.sub.count > 0)
{
command->details.sub.topics = (char **)malloc(sizeof(char *) * command->details.sub.count);
command->details.sub.qoss = (int *)malloc(sizeof(int) * command->details.sub.count);
}
for (i = 0; i < command->details.sub.count; ++i)
{
@ -733,8 +739,13 @@ static MQTTAsync_queuedCommand* MQTTAsync_restoreCommand(char* buffer, int bufle
break;
case UNSUBSCRIBE:
command->details.sub.count = *(int*)ptr;
command->details.unsub.count = *(int*)ptr;
ptr += sizeof(int);
if (command->details.unsub.count > 0)
{
command->details.unsub.topics = (char **)malloc(sizeof(char *) * command->details.unsub.count);
}
for (i = 0; i < command->details.unsub.count; ++i)
{