修改了restoreCommand时:(1)topics指针未申请内存的问题;(2)unsub误写为sub的问题。

Signed-off-by: LeonLi <liting6680@gmail.com>
This commit is contained in:
LeonLi 2017-11-29 16:01:06 +08:00
parent c85e4a2fd6
commit cb7ed54ef7
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)
{