From 5155e9e8f38920b2c57c4dd2443fc4b49613d253 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Fri, 9 Oct 2026 16:39:00 -0400 Subject: [PATCH] qrtplib: Prevent unsafe copying of RTPRawPacket Explicitly delete the copy constructor and copy assignment operator for RTPRawPacket, which represents a received packet and manages resources that should not be duplicated through implicit shallow copies. The implicitly generated copy operations could duplicate internal pointers, leaving multiple RTPRawPacket instances referring to the same resources and potentially causing invalid ownership or double deletion. Since RTPRawPacket is not intended to be copied or assigned, prohibit both operations at compile time to prevent unsafe resource ownership. cppcheck identified the missing copy constructor and assignment operator with its noCopyConstructor and noOperatorEq warnings. Signed-off-by: Robin Getz --- qrtplib/rtprawpacket.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qrtplib/rtprawpacket.h b/qrtplib/rtprawpacket.h index 82ef6d66b..1fea29e65 100644 --- a/qrtplib/rtprawpacket.h +++ b/qrtplib/rtprawpacket.h @@ -58,6 +58,8 @@ public: */ RTPRawPacket(const uint8_t *data, std::size_t datalen, const RTPAddress& address, RTPTime &recvtime, bool rtp); ~RTPRawPacket(); + RTPRawPacket(const RTPRawPacket&) = delete; + RTPRawPacket& operator=(const RTPRawPacket&) = delete; /** Returns the pointer to the data which is contained in this packet. */ uint8_t *GetData()