fix memcpy erroneously used on overlapping buffer regions as described in #1379

This commit is contained in:
AlexandreRouma 2024-04-17 01:20:17 +02:00
parent ea08fac32e
commit 779ef7ecf1

View File

@ -41,10 +41,10 @@ namespace dsp::filter {
// Move existing data to make transition seemless // Move existing data to make transition seemless
if (_taps.size < oldTC) { if (_taps.size < oldTC) {
memcpy(buffer, &buffer[oldTC - _taps.size], (_taps.size - 1) * sizeof(D)); memmove(buffer, &buffer[oldTC - _taps.size], (_taps.size - 1) * sizeof(D));
} }
else if (_taps.size > oldTC) { else if (_taps.size > oldTC) {
memcpy(&buffer[_taps.size - oldTC], buffer, (oldTC - 1) * sizeof(D)); memmove(&buffer[_taps.size - oldTC], buffer, (oldTC - 1) * sizeof(D));
buffer::clear<D>(buffer, _taps.size - oldTC); buffer::clear<D>(buffer, _taps.size - oldTC);
} }