Count the Array#product positions in rb_len_t

An int counter overflows once an array has more than INT_MAX elements. On LP64, product with a block then yielded the element at index 1 after the one at INT_MAX, instead of the one at 2**31.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hiroshi SHIBATAandClaude Opus 5.5 committed 2026-10-13 09:46:06 +09:00
1 parent c83f90c682
commit cb86c6d7ba
1 file changed
+1 -1
Notes: git 2026-10-13 00:46:42 +00:00
+1 -1
View File
@@ -7822,7 +7822,7 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)
volatile VALUE t0 = rb_ary_hidden_new(n);
volatile VALUE t1 = Qundef;
VALUE *arrays = RARRAY_PTR(t0); /* The arrays we're computing the product of */
int *counters = ALLOCV_N(int, t1, n); /* The current position in each one */
rb_len_t *counters = ALLOCV_N(rb_len_t, t1, n); /* The current position in each one */
VALUE result = Qnil; /* The array we'll be returning, when no block given */
rb_len_t i,j;
rb_len_t resultlen = 1;