Skip to content

Commit 43e2788

Browse files
committed
Fix possible memory leak
In `MQTTAsync_receiveThread`, when `pack` is not `NULL` but none of the `if`-`else if`-conditions is fulfilled, `pack` is not freed. To fix this, an `else` block has been added to cleanup the memory of `pack`. Signed-off-by: Harald Reif <haraldr@copadata.com>
1 parent 0521dc5 commit 43e2788

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/MQTTAsyncUtils.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,6 +2320,11 @@ thread_return_type WINAPI MQTTAsync_receiveThread(void* n)
23202320
m->c->connected = 0; /* don't send disconnect packet back */
23212321
nextOrClose(m, discrc, "Received disconnect");
23222322
}
2323+
else
2324+
{
2325+
free(pack);
2326+
pack = NULL;
2327+
}
23232328
}
23242329
}
23252330
}

0 commit comments

Comments
 (0)