From 6bdca5d85e15420082ac2e79f4bae1ff7bc5edbc Mon Sep 17 00:00:00 2001 From: shyouhei Date: Mon, 19 Nov 2018 06:48:09 +0000 Subject: array.c: avoid (VALUE)-- This args[1]-- overflows when it is zero. Should do that only when we can say it is nonzero. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/array.c b/array.c index 00061019b4..b0cb48dc89 100644 --- a/array.c +++ b/array.c @@ -3598,7 +3598,8 @@ static VALUE take_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, cbarg)) { VALUE *args = (VALUE *)cbarg; - if (args[1]-- == 0) rb_iter_break(); + if (args[1] == 0) rb_iter_break(); + else args[1]--; if (argc > 1) val = rb_ary_new4(argc, argv); rb_ary_push(args[0], val); return Qnil; -- cgit v1.2.3