summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-15 15:28:55 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-15 15:28:55 +0000
commit03a93ba48da930f0f35ac83da7853cd89f94a8f4 (patch)
tree5753becb24ef64acef69b57d64630e4396322bc0
parenta732f344366688c17220989dce1cfe3cac156fe2 (diff)
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--object.c5
-rw-r--r--test/ruby/test_module.rb24
-rw-r--r--version.h2
4 files changed, 35 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f00e4ebf5..0ba5dbd6f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu Oct 16 00:20:12 2014 Eric Wong <e@80x24.org>
+
+ * 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@ruby-lang.org>
* signal.c (rb_f_kill): get rid of deadlock as unhandled and
diff --git a/object.c b/object.c
index 34eac51a1d..0d7e03a95f 100644
--- a/object.c
+++ b/object.c
@@ -203,9 +203,8 @@ rb_obj_not_equal(VALUE obj1, VALUE obj2)
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;
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 372a2d4ca5..050d17a5d3 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1957,6 +1957,30 @@ class TestModule < Test::Unit::TestCase
}
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)
diff --git a/version.h b/version.h
index 27189944d7..e9dc8dc4c8 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#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