* vm_method.c (rb_undef): should raise TypeError if klass is nil.

1.instance_eval { undef to_s } causes SEGV before this fix.
* test/ruby/test_undef.rb: new tests for undef.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2009-11-18 01:13:54 +00:00
parent e43c0bde53
commit 63c3b2d283
2 changed files with 10 additions and 0 deletions

View File

@ -1,3 +1,10 @@
Wed Nov 18 10:12:34 2009 Shugo Maeda <shugo@ruby-lang.org>
* vm_method.c (rb_undef): should raise TypeError if klass is nil.
1.instance_eval { undef to_s } causes SEGV before this fix.
* test/ruby/test_undef.rb: new tests for undef.
Wed Nov 18 08:41:42 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed Nov 18 08:41:42 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (str_utf8_nth): fixed overrun. [ruby-core:26787] * string.c (str_utf8_nth): fixed overrun. [ruby-core:26787]

View File

@ -574,6 +574,9 @@ rb_undef(VALUE klass, ID id)
{ {
rb_method_entry_t *me; rb_method_entry_t *me;
if (NIL_P(klass)) {
rb_raise(rb_eTypeError, "no class to undef method");
}
if (rb_vm_cbase() == rb_cObject && klass == rb_cObject) { if (rb_vm_cbase() == rb_cObject && klass == rb_cObject) {
rb_secure(4); rb_secure(4);
} }