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

HeapArray: Avoid writing out of bounds in internal_resize #11139

Merged

Conversation

DaZombieKiller
Copy link
Contributor

Description of Changes

The non-MSVC implementation of DynamicHeapArray<T>::internal_resize contains a buffer overrun when the new size is smaller than the previous size, as it just performs a memcpy(data, prev, prev_size) without checking the size of data. This PR fixes the problem by using min(size, prev_size) instead of prev_size.

Rationale behind Changes

This issue caused a crash when changing from 128MB RAM back to the default 32MB RAM in #11111 on Linux.

@refractionpcsx2 refractionpcsx2 merged commit d48c3cf into PCSX2:master Apr 24, 2024
12 checks passed
@refractionpcsx2
Copy link
Member

Thanks :)

@DaZombieKiller DaZombieKiller deleted the dynamicheaparray-overrun branch April 25, 2024 01:00
@coornio
Copy link
Contributor

coornio commented Apr 26, 2024

I noticed that the swap() method in DynamicHeapArray does not actually swap their sizes, so you have an issue there too :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants