Browse Source

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<RemoteDataFrame> 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 <rgetz503@gmail.com>
chirpmodem-v8.0.0
Robin Getz 1 month ago
parent
commit
0271805b54
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 10
      sdrbase/channel/remotedatablock.h

10
sdrbase/channel/remotedatablock.h

@ -29,6 +29,7 @@ @@ -29,6 +29,7 @@
#include <string.h>
#include <algorithm>
#include <QString>
#include <utility>
#include "dsp/dsptypes.h"
#define UDPSINKFEC_UDPSIZE 512
@ -170,6 +171,15 @@ public: @@ -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;

Loading…
Cancel
Save