aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--array.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/array.c b/array.c
index 6b0396753f..77a241259b 100644
--- a/array.c
+++ b/array.c
@@ -4103,7 +4103,11 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)
}
/* Otherwise, allocate and fill in an array of results */
- if (!rb_block_given_p()) {
+ if (rb_block_given_p()) {
+ /* Make defensive copies of arrays */
+ for (i = 0; i < n; i++) arrays[i] = ary_make_substitution(arrays[i]);
+ }
+ else {
result = rb_ary_new2(resultlen);
}
for (i = 0; i < resultlen; i++) {