Unverified Commit 6aa07f57 authored by Ian Craggs's avatar Ian Craggs Committed by GitHub

Merge pull request #383 from LeoonLee/master

fixd: when restore command, "topics" no malloc.
parents e46c0419 cb7ed54e
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment