aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--enum.c3
2 files changed, 7 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index a09f8c8187..12c4a60ae3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Jun 3 09:03:23 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * enum.c (enum_first): should check negative length.
+
Tue Jun 2 17:32:40 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
* enum.c (first_i): Enumerator#first should consume only what is
diff --git a/enum.c b/enum.c
index 978f850400..720fc09e41 100644
--- a/enum.c
+++ b/enum.c
@@ -654,6 +654,9 @@ enum_first(int argc, VALUE *argv, VALUE obj)
rb_scan_args(argc, argv, "01", &n);
len = NUM2LONG(n);
if (len == 0) return rb_ary_new2(0);
+ if (len < 0) {
+ rb_raise(rb_eArgError, "negative length");
+ }
ary[0] = len;
ary[1] = rb_ary_new2(len);
}