Browse Source

demoddatv/leansdr: Prevent unsafe copying of bch_engine

Explicitly delete the copy constructor and copy assignment operator for
bch_engine, which owns dynamically allocated arrays released by its
destructor.

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

Since bch_engine is not intended to be copied or assigned, prohibit both
operations at compile time, preventing 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
6e8d1efb76
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 2
      plugins/channelrx/demoddatv/leansdr/bch.h

2
plugins/channelrx/demoddatv/leansdr/bch.h

@ -95,6 +95,8 @@ struct bch_engine : bch_interface @@ -95,6 +95,8 @@ struct bch_engine : bch_interface
delete[] truncpolys;
delete[] syndpolys;
}
bch_engine(const bch_engine&) = delete;
bch_engine& operator=(const bch_engine&) = delete;
// Generate BCH parity bits.

Loading…
Cancel
Save