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/trunk@47715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e0f02160bc
commit
0ef94bd2af
@ -1,3 +1,11 @@
|
|||||||
|
Fri Sep 26 05:21:01 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]
|
||||||
|
|
||||||
Fri Sep 26 05:12:10 2014 Eric Wong <e@80x24.org>
|
Fri Sep 26 05:12:10 2014 Eric Wong <e@80x24.org>
|
||||||
|
|
||||||
* man/ruby.1: document stack size env variables
|
* man/ruby.1: document stack size env variables
|
||||||
|
5
object.c
5
object.c
@ -206,9 +206,8 @@ rb_obj_not_equal(VALUE obj1, VALUE obj2)
|
|||||||
VALUE
|
VALUE
|
||||||
rb_class_real(VALUE cl)
|
rb_class_real(VALUE cl)
|
||||||
{
|
{
|
||||||
if (cl == 0)
|
while (cl &&
|
||||||
return 0;
|
((RBASIC(cl)->flags & FL_SINGLETON) || BUILTIN_TYPE(cl) == T_ICLASS)) {
|
||||||
while ((RBASIC(cl)->flags & FL_SINGLETON) || BUILTIN_TYPE(cl) == T_ICLASS) {
|
|
||||||
cl = RCLASS_SUPER(cl);
|
cl = RCLASS_SUPER(cl);
|
||||||
}
|
}
|
||||||
return cl;
|
return cl;
|
||||||
|
@ -1971,6 +1971,30 @@ class TestModule < Test::Unit::TestCase
|
|||||||
}
|
}
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
def assert_top_method_is_private(method)
|
def assert_top_method_is_private(method)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user