Browse Source

udpsource: Prevent unsafe copying of UDPSourceSource

Explicitly delete the copy constructor and copy assignment operator for
UDPSourceSource, which manages resources that should not be shared through
implicit shallow copies.

The implicitly generated copy operations could leave multiple UDPSourceSource
instances referring to the same resources, potentially causing invalid
ownership or double deletion.

Since UDPSourceSource 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 <rgetz503@gmail.com>
chirpmodem-v8.0.0
Robin Getz 1 month ago
parent
commit
3a10e38b1e
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 2
      plugins/channeltx/udpsource/udpsourcesource.h

2
plugins/channeltx/udpsource/udpsourcesource.h

@ -37,6 +37,8 @@ class UDPSourceSource : public ChannelSampleSource {
public: public:
UDPSourceSource(); UDPSourceSource();
virtual ~UDPSourceSource(); virtual ~UDPSourceSource();
UDPSourceSource(const UDPSourceSource&) = delete;
UDPSourceSource& operator=(const UDPSourceSource&) = delete;
virtual void pull(SampleVector::iterator begin, unsigned int nbSamples); virtual void pull(SampleVector::iterator begin, unsigned int nbSamples);
virtual void pullOne(Sample& sample); virtual void pullOne(Sample& sample);

Loading…
Cancel
Save