Browse Source

demoddatv/leansdr: Prevent unsafe copying of SDR processing classes

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

The implicitly generated copy operations would shallow-copy the array
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
71c0e73e9d
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 6
      plugins/channelrx/demoddatv/leansdr/sdr.h

6
plugins/channelrx/demoddatv/leansdr/sdr.h

@ -91,6 +91,9 @@ struct auto_notch : runnable @@ -91,6 +91,9 @@ struct auto_notch : runnable
delete[] __slots;
}
auto_notch(const auto_notch&) = delete;
auto_notch& operator=(const auto_notch&) = delete;
void run()
{
while (in.readable() >= fft.size() && out.writable() >= fft.size())
@ -1052,6 +1055,9 @@ struct fir_sampler : sampler_interface<T> @@ -1052,6 +1055,9 @@ struct fir_sampler : sampler_interface<T>
delete[] shifted_coeffs;
}
fir_sampler(const fir_sampler&) = delete;
fir_sampler& operator=(const fir_sampler&) = delete;
int readahead() {
return ncoeffs - 1;
}

Loading…
Cancel
Save