Fix potential nullptr deref in free_PacketInfo_ptr
This commit is contained in:
parent
3fac706d86
commit
211715fc56
2 changed files with 2 additions and 1 deletions
|
@ -2500,7 +2500,7 @@ void UDPC_free_PacketInfo(UDPC_PacketInfo pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPC_free_PacketInfo_ptr(UDPC_PacketInfo *pInfoPtr) {
|
void UDPC_free_PacketInfo_ptr(UDPC_PacketInfo *pInfoPtr) {
|
||||||
if (pInfoPtr->data && pInfoPtr->dataSize > 0) {
|
if (pInfoPtr && pInfoPtr->data && pInfoPtr->dataSize > 0) {
|
||||||
std::free(pInfoPtr->data);
|
std::free(pInfoPtr->data);
|
||||||
pInfoPtr->data = nullptr;
|
pInfoPtr->data = nullptr;
|
||||||
pInfoPtr->dataSize = 0;
|
pInfoPtr->dataSize = 0;
|
||||||
|
|
|
@ -337,4 +337,5 @@ TEST(UDPC, free_packet_ptr) {
|
||||||
|
|
||||||
UDPC_free_PacketInfo_ptr(&pinfo);
|
UDPC_free_PacketInfo_ptr(&pinfo);
|
||||||
UDPC_free_PacketInfo_ptr(&pinfo);
|
UDPC_free_PacketInfo_ptr(&pinfo);
|
||||||
|
UDPC_free_PacketInfo_ptr(nullptr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue