diff --git a/ChangeLog b/ChangeLog index 7cd75bf441..766b9e8320 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Nov 18 10:12:34 2009 Shugo Maeda + + * 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 * string.c (str_utf8_nth): fixed overrun. [ruby-core:26787] diff --git a/vm_method.c b/vm_method.c index d1c68b58f3..215db50080 100644 --- a/vm_method.c +++ b/vm_method.c @@ -574,6 +574,9 @@ rb_undef(VALUE klass, ID id) { 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) { rb_secure(4); }