mirror of https://github.com/eclipse/paho.mqtt.c
修改了restoreCommand时:(1)topics指针未申请内存的问题;(2)unsub误写为sub的问题。
Signed-off-by: LeonLi <liting6680@gmail.com>
This commit is contained in:
parent
c85e4a2fd6
commit
cb7ed54ef7
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue