diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-16 09:30:23 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-16 09:30:23 +0000 |
commit | 1cd0ddea1bee76e77e207e0e65c2a782e0cf21f2 (patch) | |
tree | 15a0bfdf1ef2d4f5eac53f287671563a083ddf40 | |
parent | 415d5ebc2f96e04fea438cd86ad23aa94a0e1da2 (diff) | |
download | ruby-1cd0ddea1bee76e77e207e0e65c2a782e0cf21f2.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | hash.c | 5 |
2 files changed, 9 insertions, 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 @@ -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); |