From c24681a078d9eb94d7186896cd12bee527ae3750 Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Mon, 9 May 2022 20:56:43 +0200 Subject: [PATCH] Fix heap buffer overflow in Vector_compact Fixes: #1006 --- Vector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vector.c b/Vector.c index 04881503..eddbc9a6 100644 --- a/Vector.c +++ b/Vector.c @@ -292,7 +292,7 @@ void Vector_compact(Vector* this) { /* one deletion: use memmove, which should be faster */ if (this->dirty_count == 1) { - memmove(&this->array[idx], &this->array[idx + 1], (this->items - idx) * sizeof(this->array[0])); + memmove(&this->array[idx], &this->array[idx + 1], (this->items - idx - 1) * sizeof(this->array[0])); } else { /* multiple deletions */ for (int i = idx + 1; i < size; i++) {