Skip to content

Fix potential issue in wmap_cmp for dead entries #11944

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

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion weakmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,15 @@ static const rb_data_type_t weakmap_type = {
static int
wmap_cmp(st_data_t x, st_data_t y)
{
return *(VALUE *)x != *(VALUE *)y;
VALUE x_obj = *(VALUE *)x;
VALUE y_obj = *(VALUE *)y;

if (!wmap_live_p(x_obj) && !wmap_live_p(y_obj)) {
return x != y;
}
else {
return x_obj != y_obj;
}
}

static st_index_t
Expand Down
Loading