summaryrefslogtreecommitdiffstats
path: root/array.c
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-04-10 09:48:15 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-04-10 09:48:15 +0000
commit79f1b5b1a8b084d5f77dba405b91ce2415b85ec0 (patch)
tree4be10c328f64343124edca7d4469c91c7c1fc0ea /array.c
parentcc3ede1ba8b59115e1a5abf02873e92e9841a00b (diff)
downloadruby-79f1b5b1a8b084d5f77dba405b91ce2415b85ec0.tar.gz
ruby-79f1b5b1a8b084d5f77dba405b91ce2415b85ec0.tar.xz
ruby-79f1b5b1a8b084d5f77dba405b91ce2415b85ec0.zip
added some checks for request size.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/array.c b/array.c
index 74bf094f5..cecf4278f 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);