Commit 7178a5e7 authored by KOBAYASHI Shuji's avatar KOBAYASHI Shuji

Fix `Array#sample` with `MRB_INT32`

Array index became potentially negative because `uint32_t` is cast to
`mrb_int`.
parent 4aabf91e
......@@ -317,7 +317,7 @@ mrb_ary_sample(mrb_state *mrb, mrb_value ary)
for (;;) {
retry:
r = (mrb_int)rand_uint32(random) % len;
r = (mrb_int)(rand_uint32(random) % len);
for (j=0; j<i; j++) {
if (mrb_fixnum(RARRAY_PTR(result)[j]) == r) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment