* array.c (rb_ary_fill): don't raise even if length is negative.

[ruby-core:17483], [ruby-core:17661]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-07-09 12:01:08 +00:00
Родитель 0d37d00b29
Коммит 6372357ad5
2 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Wed Jul 9 20:58:16 2008 Tanaka Akira <akr@fsij.org>
* array.c (rb_ary_fill): don't raise even if length is negative.
[ruby-core:17483], [ruby-core:17661]
Wed Jul 9 20:36:31 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed Jul 9 20:36:31 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* thread_{pthread,win32}.c (native_sleep): wait until timed out. * thread_{pthread,win32}.c (native_sleep): wait until timed out.

Просмотреть файл

@ -2141,10 +2141,12 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary)
if (beg < 0) beg = 0; if (beg < 0) beg = 0;
} }
len = NIL_P(arg2) ? RARRAY_LEN(ary) - beg : NUM2LONG(arg2); len = NIL_P(arg2) ? RARRAY_LEN(ary) - beg : NUM2LONG(arg2);
if (len < 0) rb_raise(rb_eIndexError, "negative length (%ld)", len);
break; break;
} }
rb_ary_modify(ary); rb_ary_modify(ary);
if (len < 0) {
return ary;
}
if (beg >= ARY_MAX_SIZE || len > ARY_MAX_SIZE - beg) { if (beg >= ARY_MAX_SIZE || len > ARY_MAX_SIZE - beg) {
rb_raise(rb_eArgError, "argument too big"); rb_raise(rb_eArgError, "argument too big");
} }