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 + + * enum.c (enum_first): should check negative length. + Tue Jun 2 17:32:40 2009 Yukihiro Matsumoto * 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); }