summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-03 00:06:40 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-03 00:06:40 +0000
commitbd08e4d4936665364998ed900c807b4fac28ba11 (patch)
tree21cc65c6da20749e07d1d559cd31552f8b522686
parent9bbc34ac6c68ed233620b2d9f9514cce1d8a4892 (diff)
downloadruby-bd08e4d4936665364998ed900c807b4fac28ba11.tar.gz
ruby-bd08e4d4936665364998ed900c807b4fac28ba11.tar.xz
ruby-bd08e4d4936665364998ed900c807b4fac28ba11.zip
* enum.c (enum_first): should check negative length.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--enum.c3
2 files changed, 7 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index a09f8c818..12c4a60ae 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 978f85040..720fc09e4 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);
}