提交 9613cf41 编写于 作者: I Ian Craggs

Free some allocated memory under some circumstances

上级 5ce32220
/*******************************************************************************
* 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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册