summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-26 13:43:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-26 13:43:40 +0000
commitd503381ce8ac41d91c195313ea1da5f67ba8250c (patch)
tree639cc6142aa5192b43b96d10d4fb7155d8de21b7 /hash.c
parenta4b0c3c26bcf7eab7c58b00eab2a75ed7d3c31b6 (diff)
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.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index bc90ada..1694a03 100644
--- a/hash.c
+++ b/hash.c
@@ -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: