This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2530:afFindSimpleDesc - ZSTACK3.0.2中的潜在内存泄漏

Guru**** 2563960 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/zigbee-thread-group/zigbee-and-thread/f/zigbee-thread-forum/958738/cc2530-potential-memory-leak-in-affindsimpledesc---zstack3-0-2

器件型号:CC2530

在读取代码时,我注意到*pDESC 被分配为 NULL,而没有将 Rtrn 设置为 true。

注释指出 Rtrn 必须为 true 才能释放描述符内存。

在不返回 true 的情况下分配 NULL 指针看起来就像潜在的内存泄漏。
我会让您确认或不确认:

/********* ^M
*@fn afFindSimpleDesc^M
*^brief
从端点编号中查找 Simple Descriptor。@M
*^M
*^param EP - Application Endpoint to find for。^M
*^M
*@返回非零值以指示必须释放描述符内存。@M
*/^^M
uint8 ** afFindSimpleDesc( SimpleDescriptionFormat_ppt uint8 EP )^M
^M



^M epList_t *epItem = afFindEndPointDescList( EP );^M uint8 Rtrn = false;^M ^M if ( epItem )
^M M { M
如果(epItem->pfnDescCB)^M
{^M
*ppDesc = epItem->pfnDescCB( AF_descriptor_Simple , EP );^M
Rtrn = true;^M
}^M
否则^M
{^M
*ppDesc = epItem->epDesc->simpleDesc;^M
}^M
}^M
else^M
{^M
*ppDesc =空;^M
}^M
^M
返回 Rtrn;^M
}^M

很抱歉、CTRL-M -我正在从类似 Linux 的提示符中检查文件。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Mario、

    下面是 pDescCB 的说明

    // typedef 用于回调函数以检索
    端点描述符中包含的端点//描述符。
    //这将允许应用程序动态更改
    //描述符,而不使用 RAM/ROM。
    typedef void *(*pDescCB)(uint8_t type、uint8_t 端点); 

    因此 、仅当存在 pfnDescCB 时、才需要在 ZDO_ProcessSimpleDescReq (仅 引用了 afFindSimpleDesc 的位置)中稍后释放存储器、否则 会检测到 sDesc 为空、并 提供 ZDP_NOT_ACTIVE stat 以在 ZDP_SimpleDescMsg 中进行处理。  

    此致、
    Ryan