From a2f9d4932697c6c5ff665ad4337620ba2f1ecc68 Mon Sep 17 00:00:00 2001 From: Watson Date: Sun, 15 Jul 2012 23:38:57 +0900 Subject: [PATCH] should check the argument --- class.c | 1 + complex.c | 8 ++++---- rational.c | 9 +++++---- spec/frozen/tags/macruby/core/module/include_tags.txt | 1 - 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/class.c b/class.c index 2fb059ad9..e9c39c55e 100644 --- a/class.c +++ b/class.c @@ -779,6 +779,7 @@ rb_mod_included_modules(VALUE mod) VALUE rb_mod_include_p(VALUE mod, SEL sel, VALUE mod2) { + Check_Type(mod2, T_MODULE); return rb_ary_includes(rb_mod_included_modules(mod), mod2); } diff --git a/complex.c b/complex.c index c09a988a8..2288d559a 100644 --- a/complex.c +++ b/complex.c @@ -1322,10 +1322,10 @@ static VALUE nucomp_marshal_load(VALUE self, SEL sel, VALUE a) { get_dat1(self); - VALUE ary = rb_convert_type(a, T_ARRAY, "Array", "to_ary"); - GC_WB(&dat->real, RARRAY_AT(ary, 0)); - GC_WB(&dat->imag, RARRAY_AT(ary, 1)); - rb_copy_generic_ivar(self, ary); + Check_Type(a, T_ARRAY); + GC_WB(&dat->real, RARRAY_AT(a, 0)); + GC_WB(&dat->imag, RARRAY_AT(a, 1)); + rb_copy_generic_ivar(self, a); return self; } diff --git a/rational.c b/rational.c index fbfd04b1b..bb3fdd106 100644 --- a/rational.c +++ b/rational.c @@ -1583,10 +1583,11 @@ static VALUE nurat_marshal_load(VALUE self, SEL sel, VALUE a) { get_dat1(self); - VALUE ary = rb_convert_type(a, T_ARRAY, "Array", "to_ary"); - GC_WB(&dat->num, RARRAY_AT(ary, 0)); - GC_WB(&dat->den, RARRAY_AT(ary ,1)); - rb_copy_generic_ivar(self, ary); + Check_Type(a, T_ARRAY); + GC_WB(&dat->num, RARRAY_AT(a, 0)); + GC_WB(&dat->den, RARRAY_AT(a ,1)); + rb_copy_generic_ivar(self, a); + if (f_zero_p(dat->den)) { rb_raise_zerodiv(); } diff --git a/spec/frozen/tags/macruby/core/module/include_tags.txt b/spec/frozen/tags/macruby/core/module/include_tags.txt index e5537a7a2..6d5a09cc9 100644 --- a/spec/frozen/tags/macruby/core/module/include_tags.txt +++ b/spec/frozen/tags/macruby/core/module/include_tags.txt @@ -2,4 +2,3 @@ fails:Module#include adds all ancestor modules when a previously included module fails:Module#include doesn't include module if it is included in a super class fails:Module#include recursively includes new mixins fails:Module#include preserves ancestor order -fails:Module#include? raises a TypeError when no module was given