diff options
author | Kenichi Kamiya <[email protected]> | 2021-03-20 19:35:36 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2021-03-20 20:46:15 +0900 |
commit | 7954bb056be30e86c419fe3792064d28990a4999 (patch) | |
tree | e69e50ed25911633d8193872b4c62a12a919babd /hash.c | |
parent | 278522f0535d081ff6473f210cb45f923ff8810a (diff) |
Some Hash destructive methods ensure the receiver modifiable [Bug #17736]
refs:
* https://bugs.ruby-lang.org/issues/17736
* https://github.com/ruby/ruby/pull/4296
This commit aims to cover following methods
* Hash#select!
* Hash#filter!
* Hash#keep_if
* Hash#reject!
* Hash#delete_if
I think these are not all.
---
* Ensure the receiver is modifiable or not
* Assert the receiver is not modified
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4297
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -2476,6 +2476,7 @@ static int delete_if_i(VALUE key, VALUE value, VALUE hash) { if (RTEST(rb_yield_values(2, key, value))) { + rb_hash_modify(hash); return ST_DELETE; } return ST_CONTINUE; @@ -2705,6 +2706,7 @@ static int keep_if_i(VALUE key, VALUE value, VALUE hash) { if (!RTEST(rb_yield_values(2, key, value))) { + rb_hash_modify(hash); return ST_DELETE; } return ST_CONTINUE; |