summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-03 04:05:37 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-03 04:05:37 +0000
commit330be69e4310886cc0d54356b2273113d288d9b1 (patch)
treed319dbd6c0ec0dac19b8e559b26c71b71ab39f89
parentbd85292d3fa7a3164deae2ef2a4a7d89f3633738 (diff)
* array.c (rb_ary_{permutation,combination,product}): must not use
ary_discard on strings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--array.c10
2 files changed, 10 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 1162d054392..555deb38e83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Aug 3 13:05:22 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * array.c (rb_ary_{permutation,combination,product}): must not use
+ ary_discard on strings.
+
Mon Aug 3 00:32:00 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* random.c (rb_random_int): arguments have to be converted to
diff --git a/array.c b/array.c
index bf471879060..0695fcf2b12 100644
--- a/array.c
+++ b/array.c
@@ -3748,8 +3748,8 @@ rb_ary_permutation(int argc, VALUE *argv, VALUE ary)
for (i = 0; i < n; i++) used[i] = 0; /* initialize array */
permute0(n, r, p, 0, used, ary0); /* compute and yield permutations */
- ary_discard(t0);
- ary_discard(t1);
+ rb_str_resize(t0, 0L);
+ rb_str_resize(t1, 0L);
RBASIC(ary0)->klass = rb_cArray;
}
return ary;
@@ -3839,7 +3839,7 @@ rb_ary_combination(VALUE ary, VALUE num)
stack[lev--]++;
} while (lev && (stack[lev+1]+n == len+lev+1));
}
- ary_discard(t0);
+ rb_str_resize(t0, 0L);
ary_discard(cc);
}
return ary;
@@ -3918,8 +3918,8 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)
counters[m]++;
}
}
- ary_discard(t0);
- ary_discard(t1);
+ rb_str_resize(t0, 0L);
+ rb_str_resize(t1, 0L);
return result;
}