diff --git a/ChangeLog b/ChangeLog index 35c2d1ee71..5001dabf04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Apr 10 18:42:13 2003 Tadayoshi Funaba + + * array.c (rb_ary_times): added some checks for request size. + Thu Apr 10 03:22:38 2003 Yukihiro Matsumoto * variable.c (rb_mod_name): always return empty string for diff --git a/array.c b/array.c index 74bf094f51..cecf4278f1 100644 --- a/array.c +++ b/array.c @@ -1529,9 +1529,13 @@ rb_ary_times(ary, times) } len = NUM2LONG(times); + if (len == 0) return rb_ary_new2(0); if (len < 0) { rb_raise(rb_eArgError, "negative argument"); } + if (LONG_MAX/len < RARRAY(ary)->len) { + rb_raise(rb_eArgError, "argument too big"); + } len *= RARRAY(ary)->len; ary2 = ary_new(rb_obj_class(ary), len);