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 /hash.c | |
parent | 415d5ebc2f96e04fea438cd86ad23aa94a0e1da2 (diff) |
* 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
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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); |