From 4a802fe9ebd5b535c4354f74cd8cd9f3916d8eed Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Fri, 9 Oct 2026 16:27:56 -0400 Subject: [PATCH] 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 --- plugins/channelrx/demoddatv/leansdr/dsp.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/channelrx/demoddatv/leansdr/dsp.h b/plugins/channelrx/demoddatv/leansdr/dsp.h index 77d985cd3..739e8b595 100644 --- a/plugins/channelrx/demoddatv/leansdr/dsp.h +++ b/plugins/channelrx/demoddatv/leansdr/dsp.h @@ -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 delete[] shifted_coeffs; } + fir_resampler(const fir_resampler&) = delete; + fir_resampler& operator=(const fir_resampler&) = delete; + void run() { if (in.readable() < ncoeffs)