summaryrefslogtreecommitdiffhomepage
path: root/src/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/array.c')
-rw-r--r--src/array.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/array.c b/src/array.c
index 0f52c38ef..ccd22674e 100644
--- a/src/array.c
+++ b/src/array.c
@@ -764,6 +764,9 @@ mrb_ary_first(mrb_state *mrb, mrb_value self)
if (mrb_get_args(mrb, "|i", &size) == 0) {
return (a->len > 0)? a->ptr[0]: mrb_nil_value();
}
+ if (size < 0) {
+ mrb_raise(mrb, E_ARGUMENT_ERROR, "negative array size");
+ }
if (size > a->len) size = a->len;
if (a->flags & MRB_ARY_SHARED) {