Commit cb7ed54e authored by LeonLi's avatar LeonLi

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

Signed-off-by: 's avatarLeonLi <liting6680@gmail.com>
parent c85e4a2f
...@@ -718,6 +718,12 @@ static MQTTAsync_queuedCommand* MQTTAsync_restoreCommand(char* buffer, int bufle ...@@ -718,6 +718,12 @@ static MQTTAsync_queuedCommand* MQTTAsync_restoreCommand(char* buffer, int bufle
case SUBSCRIBE: case SUBSCRIBE:
command->details.sub.count = *(int*)ptr; command->details.sub.count = *(int*)ptr;
ptr += sizeof(int); 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) for (i = 0; i < command->details.sub.count; ++i)
{ {
...@@ -733,8 +739,13 @@ static MQTTAsync_queuedCommand* MQTTAsync_restoreCommand(char* buffer, int bufle ...@@ -733,8 +739,13 @@ static MQTTAsync_queuedCommand* MQTTAsync_restoreCommand(char* buffer, int bufle
break; break;
case UNSUBSCRIBE: case UNSUBSCRIBE:
command->details.sub.count = *(int*)ptr; command->details.unsub.count = *(int*)ptr;
ptr += sizeof(int); 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) 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