diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-10-12 14:34:37 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-10-12 14:34:37 +0000 |
commit | 2f3f14b9375b7b188ad0b65044f7ad1d30855901 (patch) | |
tree | 2faf4ce23ee54212f478203c6be6a53de7942b70 /array.c | |
parent | b8bd8a6ce519baad544d960cfce3d49a5b038ff8 (diff) | |
download | ruby-2f3f14b9375b7b188ad0b65044f7ad1d30855901.tar.gz ruby-2f3f14b9375b7b188ad0b65044f7ad1d30855901.tar.xz ruby-2f3f14b9375b7b188ad0b65044f7ad1d30855901.zip |
* array.c (rb_ary_combination): fixed memory corruption due to too
small memory allocation
* array.c (rb_ary_product): accessing out of memory bounds.
condition fixed.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -3112,7 +3112,7 @@ rb_ary_combination(VALUE ary, VALUE num) } } else { - volatile VALUE t0 = tmpbuf(n, sizeof(long)); + volatile VALUE t0 = tmpbuf(n+1, sizeof(long)); long *stack = (long*)RSTRING_PTR(t0); long nlen = combi_len(len, n); volatile VALUE cc = rb_ary_new2(n); @@ -3199,7 +3199,7 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary) */ m = n-1; counters[m]++; - while (m >= 0 && counters[m] == RARRAY_LEN(arrays[m])) { + while (m > 0 && counters[m] == RARRAY_LEN(arrays[m])) { counters[m] = 0; m--; counters[m]++; |