Skip to content

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
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