summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/io.c b/io.c
index f2c64989df..1eb48dd19b 100644
--- a/io.c
+++ b/io.c
@@ -11518,6 +11518,8 @@ io_s_foreach(VALUE v)
struct getline_arg *arg = (void *)v;
VALUE str;
+ if (arg->limit == 0)
+ rb_raise(rb_eArgError, "invalid limit: 0 for foreach");
while (!NIL_P(str = rb_io_getline_1(arg->rs, arg->limit, arg->chomp, arg->io))) {
rb_lastline_set(str);
rb_yield(str);