diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-26 13:43:40 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-26 13:43:40 +0000 |
commit | d503381ce8ac41d91c195313ea1da5f67ba8250c (patch) | |
tree | 639cc6142aa5192b43b96d10d4fb7155d8de21b7 /hash.c | |
parent | a4b0c3c26bcf7eab7c58b00eab2a75ed7d3c31b6 (diff) | |
download | ruby-d503381ce8ac41d91c195313ea1da5f67ba8250c.tar.gz |
hash.c: cut off if recursion
* hash.c (rb_hash): cut off if recursion detected to get rid of stack
overflow. [ruby-core:58567] [Bug #9151]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -76,10 +76,17 @@ rb_any_cmp(VALUE a, VALUE b) return !rb_eql(a, b); } +static VALUE +hash_recursive(VALUE obj, VALUE arg, int recurse) +{ + if (recurse) return INT2FIX(0); + return rb_funcallv(obj, id_hash, 0, 0); +} + VALUE rb_hash(VALUE obj) { - VALUE hval = rb_funcall(obj, id_hash, 0); + VALUE hval = rb_exec_recursive(hash_recursive, obj, 0); retry: switch (TYPE(hval)) { case T_FIXNUM: |