Browse Source

demoddatv/leansdr: Prevent unsafe copying of hdlc_dec

Explicitly delete the copy constructor and copy assignment operator for
hdlc_dec, which owns a dynamically allocated frame buffer released by its
destructor.

The implicitly generated copy operations would shallow-copy the framebuf
pointer, leaving multiple hdlc_dec instances referring to the same
allocation and potentially causing double deletion.

Since hdlc_dec 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
33efaf5b74
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 3
      plugins/channelrx/demoddatv/leansdr/hdlc.h

3
plugins/channelrx/demoddatv/leansdr/hdlc.h

@ -55,6 +55,9 @@ struct hdlc_dec @@ -55,6 +55,9 @@ struct hdlc_dec
delete[] framebuf;
}
hdlc_dec(const hdlc_dec&) = delete;
hdlc_dec& operator=(const hdlc_dec&) = delete;
void reset()
{
shiftreg = 0;

Loading…
Cancel
Save