请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:CC3235SF 工具与软件:
您好!
我只想让您知道我在函数 mqtt_if_Subscribe() 模块 mqtt_if.c 中发现的问题 以下是简要说明:
添加新主题后、它将成为设备订阅的链接主题列表的标题。 如果 MQTT 主题订阅失败、在 本例中、因为数据包不可发送给代理、 为该主题分配的内存将被释放。 但是、链接列表的标题不会恢复到先前添加的主题。 然后,释放的内存被重用,现在主题链接列表的头已损坏。 代理发出的下一条消息导致需要查找该主题、以及 Kaboom 内存故障。
// adding the topic node to the linked list
topicEntry->next = mMQTTContext.head;
mMQTTContext.head = topicEntry;
if(mMQTTContext.moduleState == MQTT_STATE_CONNECTED){
ret = MQTTClient_subscribe(mMQTTContext.mqttClient, &topicEntry->topicParams, 1);
// if the client fails to subscribe to the node remove the topic from the list
if(ret < 0){
//LOG_ERROR("subscribe failed %d. removing topic from list", ret);
free(topicEntry->topicParams.topic);
free(topicEntry);
}
}