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

Added test for servo#353 and fixed use after free bug that causes it #354

Merged
merged 1 commit into from
May 10, 2024

Conversation

josephg
Copy link
Contributor

@josephg josephg commented May 10, 2024

I took a look at what was causing #353.

Turns out the push_heap function was placing the heap pointer into a local variable before calling self.reserve(). reserve in turn calls realloc() - which can free the old heap allocation & create a new one. When this happens, the old ptr is becomes invalid.

The code was writing to this invalid pointer (ptr.as_ptr().add(len).write(value)) - which is a use-after-free bug.

This PR fixes the bug and adds a regression test.

Copy link
Collaborator

@mbrubeck mbrubeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mbrubeck mbrubeck added this pull request to the merge queue May 10, 2024
Merged via the queue into servo:v2 with commit 6dac8c8 May 10, 2024
5 checks passed
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.

2 participants