mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* hash.c (rb_hash_aset, recursive_hash): rejects recursive hash.
[ruby-core:22921] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
415d5ebc2f
commit
1cd0ddea1b
2 changed files with 9 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
Thu Jul 16 18:30:20 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* hash.c (rb_hash_aset, recursive_hash): rejects recursive hash.
|
||||
[ruby-core:22921]
|
||||
|
||||
Thu Jul 16 18:28:09 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* id.c (Init_id), vm.c (vm_exec): @#__ThrowState__ is no longer
|
||||
|
|
5
hash.c
5
hash.c
|
@ -1016,6 +1016,9 @@ VALUE
|
|||
rb_hash_aset(VALUE hash, VALUE key, VALUE val)
|
||||
{
|
||||
rb_hash_modify(hash);
|
||||
if (hash == key) {
|
||||
rb_raise(rb_eArgError, "recursive key for hash");
|
||||
}
|
||||
if (RHASH(hash)->ntbl->type == &identhash || rb_obj_class(key) != rb_cString) {
|
||||
st_insert(RHASH(hash)->ntbl, key, val);
|
||||
}
|
||||
|
@ -1546,7 +1549,7 @@ recursive_hash(VALUE hash, VALUE dummy, int recur)
|
|||
VALUE hval;
|
||||
|
||||
if (recur) {
|
||||
return LONG2FIX(0);
|
||||
rb_raise(rb_eArgError, "recursive key for hash");
|
||||
}
|
||||
if (!RHASH(hash)->ntbl)
|
||||
return LONG2FIX(0);
|
||||
|
|
Loading…
Add table
Reference in a new issue