diff --git a/src/UDPConnection.cpp b/src/UDPConnection.cpp index b8b0f22..8f9e327 100644 --- a/src/UDPConnection.cpp +++ b/src/UDPConnection.cpp @@ -2500,7 +2500,7 @@ void UDPC_free_PacketInfo(UDPC_PacketInfo pInfo) { } 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); pInfoPtr->data = nullptr; pInfoPtr->dataSize = 0; diff --git a/src/test/TestUDPC.cpp b/src/test/TestUDPC.cpp index 75ba976..37bd719 100644 --- a/src/test/TestUDPC.cpp +++ b/src/test/TestUDPC.cpp @@ -337,4 +337,5 @@ TEST(UDPC, free_packet_ptr) { UDPC_free_PacketInfo_ptr(&pinfo); UDPC_free_PacketInfo_ptr(&pinfo); + UDPC_free_PacketInfo_ptr(nullptr); }