kohi
kohi copied to clipboard
[BUG] Moves wrong length in darray_pop_at.
When popping from a darray by index there is an issue when moving the data.
// If not on the last element, snip out the entry and copy the rest inward.
if (index != length - 1) {
kcopy_memory(
(void*)(addr + (index * stride)),
(void*)(addr + ((index + 1) * stride)),
stride * (length - (index - 1)));
}
The size of stride * (length - (index - 1))
will be too large, the correct value should be stride * (length - (index + 1))
.
This has the potential to lead to memory corruption if not fixed.