Fix invalid read

This commit is contained in:
2023-11-15 16:26:02 +01:00
parent a02cce0966
commit 79adcad8de
2 changed files with 13 additions and 3 deletions

View File

@@ -79,8 +79,10 @@ i32 _bzArrayIns(void *arr, i32 idx) {
BZ_ASSERT(idx >= 0 && idx <= head->size);
BZ_ASSERT(head->size + 1 <= head->capacity);
bzMemMove((u8 *) arr + (idx + 1) * head->stride,
(u8 *) arr + idx * head->stride, head->stride);
if (idx != head->size) {
bzMemMove((u8 *) arr + (idx + 1) * head->stride,
(u8 *) arr + idx * head->stride, head->stride);
}
head->size++;
return idx;
}