aboutsummaryrefslogtreecommitdiffstats
path: root/range.c
diff options
context:
space:
mode:
Diffstat (limited to 'range.c')
-rw-r--r--range.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/range.c b/range.c
index 41c1cf088b..f5a8d15f5d 100644
--- a/range.c
+++ b/range.c
@@ -332,8 +332,11 @@ range_step(int argc, VALUE *argv, VALUE range)
if (!EXCL(range))
end += 1;
- for (i = FIX2LONG(b); i < end; i += unit) {
+ i = FIX2LONG(b);
+ while (i < end) {
rb_yield(LONG2NUM(i));
+ if (i + unit < i) break;
+ i += unit;
}
}
else {