diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | include/ruby/ruby.h | 2 | ||||
-rw-r--r-- | struct.c | 2 |
3 files changed, 9 insertions, 2 deletions
@@ -1,3 +1,10 @@ +Wed Oct 7 16:06:30 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * include/ruby/ruby.h (rb_long2int): evalates the argument only + once. + + * struct.c (rb_struct_alloc): check array length overflow. + Wed Oct 7 09:23:49 2009 NARUSE, Yui <naruse@ruby-lang.org> * string.c (rb_str_inspect): don't assign -1 to unsigned int. diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 8fc1eb0f0..33a35ce43 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -653,7 +653,7 @@ NORETURN(void rb_out_of_int(SIGNED_VALUE num)); int i = (int)(n); \ if ((long)i != (n)) rb_out_of_int(n) #ifdef __GNUC__ -#define rb_long2int(i2l_n) __extension__ ({rb_long2int_internal(i2l_n, i2l_i); i2l_i;}) +#define rb_long2int(n) __extension__ ({long i2l_n = (n); rb_long2int_internal(i2l_n, i2l_i); i2l_i;}) #else static inline int rb_long2int(long n) {rb_long2int_internal(n, i); return i;} @@ -415,7 +415,7 @@ struct_alloc(VALUE klass) VALUE rb_struct_alloc(VALUE klass, VALUE values) { - return rb_class_new_instance(RARRAY_LEN(values), RARRAY_PTR(values), klass); + return rb_class_new_instance(RARRAY_LENINT(values), RARRAY_PTR(values), klass); } VALUE |