[前][次][番号順一覧][スレッド一覧]

ruby-changes:41768

From: nobu <ko1@a...>
Date: Tue, 16 Feb 2016 18:24:45 +0900 (JST)
Subject: [ruby-changes:41768] nobu:r53842 (trunk): numeric.c: fix segfault

nobu	2016-02-16 18:25:08 +0900 (Tue, 16 Feb 2016)

  New Revision: 53842

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53842

  Log:
    numeric.c: fix segfault
    
    * numeric.c (compare_with_zero): fix variable name, rb_cmperr
      requires VALUEs but not an ID.

  Modified files:
    trunk/ChangeLog
    trunk/numeric.c
    trunk/test/ruby/test_numeric.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53841)
+++ ChangeLog	(revision 53842)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Feb 16 18:24:38 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* numeric.c (compare_with_zero): fix variable name, rb_cmperr
+	  requires VALUEs but not an ID.
+
 Tue Feb 16 17:34:18 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* dir.c (rb_dir_s_empty_p): add Dir.empty? method, which tells the
Index: test/ruby/test_numeric.rb
===================================================================
--- test/ruby/test_numeric.rb	(revision 53841)
+++ test/ruby/test_numeric.rb	(revision 53842)
@@ -348,4 +348,14 @@ class TestNumeric < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_numeric.rb#L348
     assert_not_operator(1, :eql?, 1.0)
     assert_not_operator(1, :eql?, 2)
   end
+
+  def test_coerced_remainder
+    assert_separately([], <<-'end;')
+      x = Class.new do
+        def coerce(a) [self, a]; end
+        def %(a) self; end
+      end.new
+      assert_raise(ArgumentError) {1.remainder(x)}
+    end;
+  end
 end
Index: numeric.c
===================================================================
--- numeric.c	(revision 53841)
+++ numeric.c	(revision 53842)
@@ -168,7 +168,7 @@ compare_with_zero(VALUE num, ID mid) https://github.com/ruby/ruby/blob/trunk/numeric.c#L168
     VALUE zero = INT2FIX(0);
     VALUE r = rb_check_funcall(num, mid, 1, &zero);
     if (r == Qundef) {
-	rb_cmperr(mid, zero);
+	rb_cmperr(num, zero);
     }
     return r;
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]