mirror of https://github.com/eclipse/paho.mqtt.c
Free some allocated memory under some circumstances
This commit is contained in:
parent
5ce322200d
commit
9613cf419c
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2022 IBM Corp.
|
||||
* Copyright (c) 2009, 2023 IBM Corp.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v2.0
|
||||
|
|
@ -340,16 +340,29 @@ int MQTTPersistence_restorePackets(Clients *c)
|
|||
buffer = NULL;
|
||||
}
|
||||
if (msgkeys[i])
|
||||
{
|
||||
free(msgkeys[i]);
|
||||
msgkeys[i] = NULL;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (msgkeys)
|
||||
free(msgkeys);
|
||||
}
|
||||
Log(TRACE_MINIMUM, -1, "%d sent messages and %d received messages restored for client %s\n",
|
||||
msgs_sent, msgs_rcvd, c->clientID);
|
||||
MQTTPersistence_wrapMsgID(c);
|
||||
exit:
|
||||
if (msgkeys)
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < nkeys; ++i)
|
||||
{
|
||||
if (msgkeys[i])
|
||||
free(msgkeys[i]);
|
||||
}
|
||||
free(msgkeys);
|
||||
}
|
||||
if (buffer)
|
||||
free(buffer);
|
||||
FUNC_EXIT_RC(rc);
|
||||
return rc;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue