kohi icon indicating copy to clipboard operation
kohi copied to clipboard

[BUG] Moves wrong length in darray_pop_at.

Open NoRines opened this issue 5 months ago • 1 comments

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.

NoRines avatar Sep 05 '24 08:09 NoRines