From 0271805b5499ddab28179a310f2eb60e6a8eb76b Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Fri, 9 Oct 2026 16:40:08 -0400 Subject: [PATCH] channel: Prevent unsafe copying of RemoteDataFrame Delete the copy constructor and copy assignment operator to prevent shallow copies of the dynamically allocated m_superBlocks array, which could lead to double deletion. Add a move constructor that transfers ownership of m_superBlocks and nulls the source pointer, allowing std::vector to relocate elements safely during resize. cppcheck identified the missing copy constructor and assignment operator with its noCopyConstructor and noOperatorEq warnings. Signed-off-by: Robin Getz --- sdrbase/channel/remotedatablock.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sdrbase/channel/remotedatablock.h b/sdrbase/channel/remotedatablock.h index e7f0af27b..38c8a835a 100644 --- a/sdrbase/channel/remotedatablock.h +++ b/sdrbase/channel/remotedatablock.h @@ -29,6 +29,7 @@ #include #include #include +#include #include "dsp/dsptypes.h" #define UDPSINKFEC_UDPSIZE 512 @@ -170,6 +171,15 @@ public: ~RemoteDataFrame() { delete[] m_superBlocks; } + RemoteDataFrame(const RemoteDataFrame&) = delete; + RemoteDataFrame& operator=(const RemoteDataFrame&) = delete; + RemoteDataFrame(RemoteDataFrame&& other) : + m_txControlBlock(std::move(other.m_txControlBlock)), + m_rxControlBlock(std::move(other.m_rxControlBlock)), + m_superBlocks(other.m_superBlocks) + { + other.m_superBlocks = nullptr; + } RemoteTxControlBlock m_txControlBlock; RemoteRxControlBlock m_rxControlBlock; RemoteSuperBlock *m_superBlocks;