mirror of
https://github.com/ruby/ruby.git
synced 2025-09-20 11:03:58 +02:00
Add missing write barrier for Hash#transform_values{,!}
21994b7fd6
removed the write barrier that was present in rb_hash_aset(). Re-insert it to not crash during GC. [Bug #16689] (cherry picked from commit713dc619f5
)
This commit is contained in:
parent
95c3bb6c42
commit
2a3027b7b5
1 changed files with 4 additions and 3 deletions
7
hash.c
7
hash.c
|
@ -3156,7 +3156,8 @@ static int
|
||||||
transform_values_foreach_replace(st_data_t *key, st_data_t *value, st_data_t argp, int existing)
|
transform_values_foreach_replace(st_data_t *key, st_data_t *value, st_data_t argp, int existing)
|
||||||
{
|
{
|
||||||
VALUE new_value = rb_yield((VALUE)*value);
|
VALUE new_value = rb_yield((VALUE)*value);
|
||||||
*value = new_value;
|
VALUE hash = (VALUE)argp;
|
||||||
|
RB_OBJ_WRITE(hash, value, new_value);
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3186,7 +3187,7 @@ rb_hash_transform_values(VALUE hash)
|
||||||
result = hash_dup(hash, rb_cHash, 0);
|
result = hash_dup(hash, rb_cHash, 0);
|
||||||
|
|
||||||
if (!RHASH_EMPTY_P(hash)) {
|
if (!RHASH_EMPTY_P(hash)) {
|
||||||
rb_hash_stlike_foreach_with_replace(result, transform_values_foreach_func, transform_values_foreach_replace, 0);
|
rb_hash_stlike_foreach_with_replace(result, transform_values_foreach_func, transform_values_foreach_replace, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -3216,7 +3217,7 @@ rb_hash_transform_values_bang(VALUE hash)
|
||||||
rb_hash_modify_check(hash);
|
rb_hash_modify_check(hash);
|
||||||
|
|
||||||
if (!RHASH_TABLE_EMPTY_P(hash)) {
|
if (!RHASH_TABLE_EMPTY_P(hash)) {
|
||||||
rb_hash_stlike_foreach_with_replace(hash, transform_values_foreach_func, transform_values_foreach_replace, 0);
|
rb_hash_stlike_foreach_with_replace(hash, transform_values_foreach_func, transform_values_foreach_replace, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue