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

ruby-changes:49997

From: normal <ko1@a...>
Date: Wed, 31 Jan 2018 04:35:19 +0900 (JST)
Subject: [ruby-changes:49997] normal:r62115 (trunk): proc: fix super_method segfault after bind

normal	2018-01-31 04:35:12 +0900 (Wed, 31 Jan 2018)

  New Revision: 62115

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

  Log:
    proc: fix super_method segfault after bind
    
    * proc.c: handle undefined iclass
      [ruby-core:85231] [Bug #14421]
    
    From: Eric Wong <e@8...>

  Modified files:
    trunk/proc.c
    trunk/test/ruby/test_method.rb
Index: proc.c
===================================================================
--- proc.c	(revision 62114)
+++ proc.c	(revision 62115)
@@ -2725,6 +2725,7 @@ method_super_method(VALUE method) https://github.com/ruby/ruby/blob/trunk/proc.c#L2725
 
     TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
     iclass = data->iclass;
+    if (!iclass) return Qnil;
     super_class = RCLASS_SUPER(RCLASS_ORIGIN(iclass));
     mid = data->me->called_id;
     if (!super_class) return Qnil;
Index: test/ruby/test_method.rb
===================================================================
--- test/ruby/test_method.rb	(revision 62114)
+++ test/ruby/test_method.rb	(revision 62115)
@@ -926,6 +926,11 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L926
     assert_equal(m1.source_location, m2.source_location, bug)
   end
 
+  def test_super_method_after_bind
+    assert_nil String.instance_method(:length).bind(String.new).super_method,
+      '[ruby-core:85231] [Bug #14421]'
+  end
+
   def rest_parameter(*rest)
     rest
   end

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

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