1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* array.c (rb_ary_fill): should adjust array length correctly when

an array is expanded in the fill process.  [ruby-core:06625]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2005-11-15 05:42:36 +00:00
parent a1fe60779b
commit 956296495b
2 changed files with 9 additions and 4 deletions

View file

@ -1,3 +1,8 @@
Tue Nov 15 14:39:16 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_fill): should adjust array length correctly when
an array is expanded in the fill process. [ruby-core:06625]
Mon Nov 14 23:49:57 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_s_readlink): ERANGE will occur only on GPFS.

View file

@ -1100,6 +1100,7 @@ rb_ary_insert(int argc, VALUE *argv, VALUE ary)
{
long pos;
if (argc == 1) return ary;
if (argc < 1) {
rb_raise(rb_eArgError, "wrong number of arguments (at least 1)");
}
@ -1107,11 +1108,9 @@ rb_ary_insert(int argc, VALUE *argv, VALUE ary)
if (pos == -1) {
pos = RARRAY(ary)->len;
}
else if (pos < 0) {
if (pos < 0) {
pos++;
}
if (argc == 1) return ary;
rb_ary_splice(ary, pos, 0, rb_ary_new4(argc - 1, argv + 1));
return ary;
}
@ -2141,7 +2140,6 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary)
if (beg > RARRAY(ary)->len) {
rb_mem_clear(RARRAY(ary)->ptr + RARRAY(ary)->len, end - RARRAY(ary)->len);
}
RARRAY(ary)->len = end;
}
if (block_p) {
@ -2152,9 +2150,11 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary)
v = rb_yield(LONG2NUM(i));
if (i>=RARRAY(ary)->len) break;
RARRAY(ary)->ptr[i] = v;
RARRAY(ary)->len = i+1;
}
}
else {
RARRAY(ary)->len = end;
p = RARRAY(ary)->ptr + beg;
pend = p + len;
while (p < pend) {