From 94ab139bc9df6016090596468f4139b1772ad882 Mon Sep 17 00:00:00 2001 From: marcandre Date: Fri, 2 Apr 2010 22:44:17 +0000 Subject: * array.c (rb_ary_product): Make defensive copy in case of block... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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++) { -- cgit v1.2.3