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

opendir and friends: Fix race condition when uv_dir_t pointer doesn't change between allocations #598

Merged
merged 1 commit into from
May 5, 2022

Conversation

squeek502
Copy link
Member

If opendir/closedir was called in a loop, it was possible for the uv_dir_t pointer to always be the same between calls, and due to how we kept track of the 'closed' state of the uv_dir_t by its pointer, this could lead to freeing things twice, or freeing the memory before a readdir call, etc.

Instead, we now use a wrapping luv_dir_t and normal Lua references to keep track of the state

Fixes #597

… change between allocations

If opendir/closedir was called in a loop, it was possible for the uv_dir_t pointer to always be the same between calls, and due to how we kept track of the 'closed' state of the uv_dir_t by its pointer, this could lead to freeing things twice, or freeing the memory before a readdir call, etc.

Instead, we now use a wrapping luv_dir_t and normal Lua references to keep track of the state

Fixes luvit#597
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.

Double free in fs_closedir
2 participants