From f0fdd8e461dfd70ca9ac98a79addad43f86556a6 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Wed, 3 Apr 2024 17:20:34 -0300 Subject: [PATCH] cfl_array: fix memory overlap when removing from array by index. Signed-off-by: Phillip Whelan --- src/cfl_array.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cfl_array.c b/src/cfl_array.c index 1bad9e8..b4a5e63 100644 --- a/src/cfl_array.c +++ b/src/cfl_array.c @@ -88,9 +88,9 @@ int cfl_array_remove_by_index(struct cfl_array *array, cfl_variant_destroy(array->entries[position]); if (position != array->entry_count - 1) { - memcpy(&array->entries[position], - &array->entries[position + 1], - sizeof(void *) * (array->entry_count - (position + 1))); + memmove(&array->entries[position], + &array->entries[position + 1], + sizeof(void *) * (array->entry_count - (position + 1))); } else { array->entries[position] = NULL;