aboutsummaryrefslogtreecommitdiffstats
path: root/array.c
diff options
context:
space:
mode:
authorLuke Gruber <luke.gru@gmail.com>2019-06-22 11:25:52 -0400
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-23 00:49:24 +0900
commitc033dc3073839e3578f1ba25d53b837974b56474 (patch)
tree87747b83fcedcc123b237bff91e4c62b21027696 /array.c
parentfd9ac1e76bc8b347ad55fdf5991839c1df4e891a (diff)
downloadruby-c033dc3073839e3578f1ba25d53b837974b56474.tar.gz
Fix issue with Array#rindex when rb_equal modifies receiver array
Fixes [Bug #15951] Closes: https://github.com/ruby/ruby/pull/2250
Diffstat (limited to 'array.c')
-rw-r--r--array.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/array.c b/array.c
index de2f80828a..8501074ebe 100644
--- a/array.c
+++ b/array.c
@@ -1805,6 +1805,9 @@ rb_ary_rindex(int argc, VALUE *argv, VALUE ary)
if (rb_equal(e, val)) {
return LONG2NUM(i);
}
+ if (i > RARRAY_LEN(ary)) {
+ break;
+ }
}
return Qnil;
}