object.c: forbid uninitialized class
* object.c (rb_class_initialize): forbid inheriting uninitialized class. another class tree not based on BasicObject cannot exist. [ruby-core:47148][Bug #6863] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a39b94d302
commit
9528358120
@ -1,3 +1,9 @@
|
|||||||
|
Thu Aug 16 19:15:23 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* object.c (rb_class_initialize): forbid inheriting uninitialized
|
||||||
|
class. another class tree not based on BasicObject cannot exist.
|
||||||
|
[ruby-core:47148][Bug #6863]
|
||||||
|
|
||||||
Thu Aug 16 11:52:06 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Aug 16 11:52:06 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* test/-ext-/test_printf.rb (Test_SPrintf#test_{taint,untrust}): use
|
* test/-ext-/test_printf.rb (Test_SPrintf#test_{taint,untrust}): use
|
||||||
|
3
object.c
3
object.c
@ -1616,6 +1616,9 @@ rb_class_initialize(int argc, VALUE *argv, VALUE klass)
|
|||||||
else {
|
else {
|
||||||
rb_scan_args(argc, argv, "01", &super);
|
rb_scan_args(argc, argv, "01", &super);
|
||||||
rb_check_inheritable(super);
|
rb_check_inheritable(super);
|
||||||
|
if (super != rb_cBasicObject && !RCLASS_SUPER(super)) {
|
||||||
|
rb_raise(rb_eTypeError, "can't inherit uninitialized class");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
RCLASS_SUPER(klass) = super;
|
RCLASS_SUPER(klass) = super;
|
||||||
rb_make_metaclass(klass, RBASIC(super)->klass);
|
rb_make_metaclass(klass, RBASIC(super)->klass);
|
||||||
|
@ -203,6 +203,8 @@ class TestClass < Test::Unit::TestCase
|
|||||||
def test_uninitialized
|
def test_uninitialized
|
||||||
assert_raise(TypeError) { Class.allocate.new }
|
assert_raise(TypeError) { Class.allocate.new }
|
||||||
assert_raise(TypeError) { Class.allocate.superclass }
|
assert_raise(TypeError) { Class.allocate.superclass }
|
||||||
|
bug6863 = '[ruby-core:47148]'
|
||||||
|
assert_raise(TypeError, bug6863) { Class.new(Class.allocate) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_nonascii_name
|
def test_nonascii_name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user