summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--class.c3
-rw-r--r--test/ruby/test_class.rb2
3 files changed, 10 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c91921fd56..b51a4050e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Feb 7 00:23:21 2010 Shugo Maeda <shugo@ruby-lang.org>
+
+ * class.c (rb_class_init_copy): raise a TypeError if the argument is
+ BasicObject. [ruby-core:27060]
+
Sat Feb 6 23:37:11 2010 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/ftp.rb (initialize): set @sock to a NullSocket instance to
diff --git a/class.c b/class.c
index 6674ae1a9d..fed2edf4ee 100644
--- a/class.c
+++ b/class.c
@@ -180,6 +180,9 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
VALUE
rb_class_init_copy(VALUE clone, VALUE orig)
{
+ if (orig == rb_cBasicObject) {
+ rb_raise(rb_eTypeError, "can't copy the root class");
+ }
if (RCLASS_SUPER(clone) != 0 || clone == rb_cBasicObject) {
rb_raise(rb_eTypeError, "already initialized class");
}
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb
index b444d4e8ab..3a0ced8be7 100644
--- a/test/ruby/test_class.rb
+++ b/test/ruby/test_class.rb
@@ -181,6 +181,8 @@ class TestClass < Test::Unit::TestCase
o = Object.new
c = class << o; self; end
assert_raise(TypeError) { c.dup }
+
+ assert_raise(TypeError) { BasicObject.dup }
end
def test_singleton_class