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

ruby-changes:35875

From: nagachika <ko1@a...>
Date: Thu, 16 Oct 2014 00:29:14 +0900 (JST)
Subject: [ruby-changes:35875] nagachika:r47957 (ruby_2_1): merge revision(s) r47715: [Backport #10282]

nagachika	2014-10-16 00:28:55 +0900 (Thu, 16 Oct 2014)

  New Revision: 47957

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

  Log:
    merge revision(s) r47715: [Backport #10282]
    
    * object.c (rb_class_real): do not dereference 0 VALUE
    
    * test/ruby/test_module.rb (test_inspect_segfault):
      Test case and bug report by Thomas Stratmann.
      [ruby-core:65214] [Bug #10282]

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/object.c
    branches/ruby_2_1/test/ruby/test_module.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 47956)
+++ ruby_2_1/ChangeLog	(revision 47957)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Thu Oct 16 00:20:12 2014  Eric Wong  <e@8...>
+
+	* object.c (rb_class_real): do not dereference 0 VALUE
+
+	* test/ruby/test_module.rb (test_inspect_segfault):
+	  Test case and bug report by Thomas Stratmann.
+	  [ruby-core:65214] [Bug #10282]
+
 Thu Oct 16 00:10:45 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* signal.c (rb_f_kill): get rid of deadlock as unhandled and
Index: ruby_2_1/object.c
===================================================================
--- ruby_2_1/object.c	(revision 47956)
+++ ruby_2_1/object.c	(revision 47957)
@@ -203,9 +203,8 @@ rb_obj_not_equal(VALUE obj1, VALUE obj2) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/object.c#L203
 VALUE
 rb_class_real(VALUE cl)
 {
-    if (cl == 0)
-        return 0;
-    while ((RBASIC(cl)->flags & FL_SINGLETON) || BUILTIN_TYPE(cl) == T_ICLASS) {
+    while (cl &&
+        ((RBASIC(cl)->flags & FL_SINGLETON) || BUILTIN_TYPE(cl) == T_ICLASS)) {
 	cl = RCLASS_SUPER(cl);
     }
     return cl;
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 47956)
+++ ruby_2_1/version.h	(revision 47957)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.4"
 #define RUBY_RELEASE_DATE "2014-10-16"
-#define RUBY_PATCHLEVEL 255
+#define RUBY_PATCHLEVEL 256
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 10
Index: ruby_2_1/test/ruby/test_module.rb
===================================================================
--- ruby_2_1/test/ruby/test_module.rb	(revision 47956)
+++ ruby_2_1/test/ruby/test_module.rb	(revision 47957)
@@ -1957,6 +1957,30 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_module.rb#L1957
     }
   end
 
+  def test_inspect_segfault
+    bug_10282 = '[ruby-core:65214] [Bug #10282]'
+    assert_separately [], <<-RUBY
+      module ShallowInspect
+        def shallow_inspect
+          "foo"
+        end
+      end
+
+      module InspectIsShallow
+        include ShallowInspect
+        alias_method :inspect, :shallow_inspect
+      end
+
+      class A
+      end
+
+      A.prepend InspectIsShallow
+
+      expect = "#<Method: A(Object)#inspect(shallow_inspect)>"
+      assert_equal expect, A.new.method(:inspect).inspect, "#{bug_10282}"
+    RUBY
+  end
+
   private
 
   def assert_top_method_is_private(method)

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r47715


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

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