From c86d8f37236c2902a89c5a38b69bb17343b2b36c Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Sun, 7 Apr 2024 20:10:42 -0400 Subject: [PATCH] array: fix memory overlap when removing from array by index. (#42) 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;