Browse Source

audio: Prevent unsafe copying of AudioNetSink

Explicitly delete the copy constructor and copy assignment operator for
AudioNetSink, which manages audio output and network resources that should
not be duplicated through implicit shallow copies.

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

Since AudioNetSink 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
74daccaa81
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 2
      sdrbase/audio/audionetsink.h

2
sdrbase/audio/audionetsink.h

@ -55,6 +55,8 @@ public: @@ -55,6 +55,8 @@ public:
AudioNetSink(QObject *parent); //!< without RTP
AudioNetSink(QObject *parent, int sampleRate, bool stereo); //!< with RTP
~AudioNetSink();
AudioNetSink(const AudioNetSink&) = delete;
AudioNetSink& operator=(const AudioNetSink&) = delete;
void setDestination(const QString& address, uint16_t port);
void addDestination(const QString& address, uint16_t port);

Loading…
Cancel
Save