Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Moves wrong length in darray_pop_at. #238

Open
NoRines opened this issue Sep 5, 2024 · 1 comment
Open

[BUG] Moves wrong length in darray_pop_at. #238

NoRines opened this issue Sep 5, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@NoRines
Copy link

NoRines commented Sep 5, 2024

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 NoRines added the bug Something isn't working label Sep 5, 2024
@dmitry-skliar
Copy link

I agree, I also tested this part once, corrected it, and then forgot to write it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants