aboutsummaryrefslogtreecommitdiffstats
path: root/compar.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-09 04:53:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-09 04:53:18 +0000
commit90c1ebbfd578419e2c3e1251b7527483f8501bc2 (patch)
treebf1a27d2a40e723f88b9a5fe1b6372d1ef144099 /compar.c
parentb203f6734434bb100bb9e7874516d7fcae47f841 (diff)
downloadruby-90c1ebbfd578419e2c3e1251b7527483f8501bc2.tar.gz
compar.c: fail if recursion
* compar.c (cmp_eq): fail if recursion. [ruby-core:57736] [Bug #9003] * thread.c (rb_exec_recursive_paired_outer): new function which is combinnation of paired and outer variants. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compar.c')
-rw-r--r--compar.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/compar.c b/compar.c
index eea76cb637..2f4db291a4 100644
--- a/compar.c
+++ b/compar.c
@@ -52,9 +52,16 @@ rb_invcmp(VALUE x, VALUE y)
}
static VALUE
+cmp_eq_recursive(VALUE arg1, VALUE arg2, int recursive)
+{
+ if (recursive) return Qfalse;
+ return rb_funcallv(arg1, cmp, 1, &arg2);
+}
+
+static VALUE
cmp_eq(VALUE *a)
{
- VALUE c = rb_funcall(a[0], cmp, 1, a[1]);
+ VALUE c = rb_exec_recursive_paired_outer(cmp_eq_recursive, a[0], a[1], a[1]);
if (NIL_P(c)) return Qfalse;
if (rb_cmpint(c, a[0], a[1]) == 0) return Qtrue;