Browse Source

chanalyzer: Prevent unsafe copying of resource-owning classes

Explicitly delete the copy constructors and copy assignment operators for
ChannelAnalyzerSink and its nested RRCHelper class.

These classes manage resources that should not be shared through implicit
shallow copies. The compiler-generated copy operations could leave multiple
objects referring to the same resources, potentially causing invalid
ownership or double deletion.

Since neither class is intended to be copied or assigned, prohibit both
operations at compile time, turning potential runtime errors into
compile-time errors.

cppcheck identified the missing copy constructors and assignment operators
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
637979ca9c
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 6
      plugins/channelrx/chanalyzer/chanalyzersink.h

6
plugins/channelrx/chanalyzer/chanalyzersink.h

@ -40,7 +40,9 @@ class ScopeVis; @@ -40,7 +40,9 @@ class ScopeVis;
class ChannelAnalyzerSink : public ChannelSampleSink {
public:
ChannelAnalyzerSink();
~ChannelAnalyzerSink();
~ChannelAnalyzerSink();
ChannelAnalyzerSink(const ChannelAnalyzerSink&) = delete;
ChannelAnalyzerSink& operator=(const ChannelAnalyzerSink&) = delete;
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
@ -63,6 +65,8 @@ private: @@ -63,6 +65,8 @@ private:
public:
RRCHelper(int flen);
~RRCHelper();
RRCHelper(const RRCHelper&) = delete;
RRCHelper& operator=(const RRCHelper&) = delete;
void setUseFFT(bool useFFT);
void create(float symbolRate, float rolloff, unsigned int samplesPerSymbol, FIRFilterRRC::Normalization normalization);
int runFilt(const std::complex<float> & in, std::complex<float> **out);

Loading…
Cancel
Save