Browse Source

demoddatv/leansdr: Prevent unsafe copying of FIR processing classes

Explicitly delete the copy constructors and copy assignment operators for
fir_filter and fir_resampler, both of which own dynamically allocated
coefficient arrays released by their destructors.

The implicitly generated copy operations would shallow-copy the coefficient
pointers, leaving multiple instances referring to the same allocations and
potentially causing double deletion.

Since neither class is intended to be copied or assigned, prohibit both
operations at compile time to prevent unsafe resource ownership.

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
4a802fe9eb
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 5
      plugins/channelrx/demoddatv/leansdr/dsp.h

5
plugins/channelrx/demoddatv/leansdr/dsp.h

@ -408,6 +408,8 @@ struct fir_filter : runnable @@ -408,6 +408,8 @@ struct fir_filter : runnable
~fir_filter() {
delete[] shifted_coeffs;
}
fir_filter(const fir_filter&) = delete;
fir_filter& operator=(const fir_filter&) = delete;
void run()
{
@ -506,6 +508,9 @@ struct fir_resampler : runnable @@ -506,6 +508,9 @@ struct fir_resampler : runnable
delete[] shifted_coeffs;
}
fir_resampler(const fir_resampler&) = delete;
fir_resampler& operator=(const fir_resampler&) = delete;
void run()
{
if (in.readable() < ncoeffs)

Loading…
Cancel
Save