1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

sample: fix sample_data_remove moving too much memory

Signed-off-by: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
This commit is contained in:
Niklas Eiling 2024-07-04 11:11:39 +02:00 committed by Niklas Eiling
parent 365bdd6288
commit 739f8fd0a8

View file

@ -311,7 +311,15 @@ void villas::node::sample_data_insert(struct Sample *smp,
void villas::node::sample_data_remove(struct Sample *smp, size_t offset,
size_t len) {
size_t sz = sizeof(smp->data[0]) * len;
if (offset + len > smp->length) {
if (offset > smp->length) {
return;
} else {
len = smp->length - offset;
}
}
size_t sz = sizeof(smp->data[0]) * (smp->length - offset - len);
memmove(&smp->data[offset], &smp->data[offset + len], sz);