Browse Source

demoddatv/leansdr: Prevent unsafe copying of pipebuf

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

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

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

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

@ -248,6 +248,9 @@ struct pipebuf : pipebuf_common @@ -248,6 +248,9 @@ struct pipebuf : pipebuf_common
delete[] buf;
}
pipebuf(const pipebuf&) = delete;
pipebuf& operator=(const pipebuf&) = delete;
int sizeofT() {
return sizeof(T);
}

Loading…
Cancel
Save