Fix heap buffer overflow in Vector_compact

Fixes: #1006
This commit is contained in:
Benny Baumann 2022-05-09 20:56:43 +02:00 committed by BenBE
parent 2da8f71209
commit c24681a078
1 changed files with 1 additions and 1 deletions

View File

@ -292,7 +292,7 @@ void Vector_compact(Vector* this) {
/* one deletion: use memmove, which should be faster */ /* one deletion: use memmove, which should be faster */
if (this->dirty_count == 1) { 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 { } else {
/* multiple deletions */ /* multiple deletions */
for (int i = idx + 1; i < size; i++) { for (int i = idx + 1; i < size; i++) {