aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--array.c9
2 files changed, 9 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index b0c0f6da2e..864540cdcf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Aug 3 00:34:20 2013 Masaki Matsushita <glass.saga@gmail.com>
+
+ * array.c (rb_ary_zip): use rb_ary_new2() to create buffer
+ if rb_block_arity() > 1.
+
Sat Aug 3 00:12:00 2013 Masaki Matsushita <glass.saga@gmail.com>
* NEWS: Add the description that IO#seek supports SEEK_DATA
diff --git a/array.c b/array.c
index b1ce74f98a..56a5310c98 100644
--- a/array.c
+++ b/array.c
@@ -3162,15 +3162,14 @@ rb_ary_zip(int argc, VALUE *argv, VALUE ary)
result = rb_ary_new2(len);
if (block_given && arity > 1) {
- int yield_argc = argc + 1;
- VALUE *yield_argv = ALLOC_N(VALUE, yield_argc);
+ VALUE tmp = rb_ary_new2(argc+1);
for (i=0; i<RARRAY_LEN(ary); i++) {
- yield_argv[0] = RARRAY_AREF(ary, i);
+ rb_ary_store(tmp, 0, RARRAY_AREF(ary, i));
for (j=0; j<argc; j++) {
- yield_argv[j+1] = rb_ary_elt(argv[j], i);
+ rb_ary_store(tmp, j+1, rb_ary_elt(argv[j], i));
}
- rb_yield_values2(yield_argc, yield_argv);
+ rb_yield_values2(argc+1, RARRAY_RAWPTR(tmp));
}
}
else {