mirror of
https://github.com/ruby/ruby.git
synced 2025-08-16 05:59:00 +02:00
merge revision(s) 17470:17472:
* array.c (rb_ary_store, rb_ary_splice): not depend on unspecified behavior at integer overflow. * string.c (str_buf_cat): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@17480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
594a34beda
commit
855e79f3de
4 changed files with 34 additions and 37 deletions
6
array.c
6
array.c
|
@ -391,7 +391,7 @@ rb_ary_store(ary, idx, val)
|
|||
if (new_capa < ARY_DEFAULT_SIZE) {
|
||||
new_capa = ARY_DEFAULT_SIZE;
|
||||
}
|
||||
else if (new_capa >= ARY_MAX_SIZE - idx) {
|
||||
if (new_capa >= ARY_MAX_SIZE - idx) {
|
||||
new_capa = (ARY_MAX_SIZE - idx) / 2;
|
||||
}
|
||||
new_capa += idx;
|
||||
|
@ -1094,10 +1094,10 @@ rb_ary_splice(ary, beg, len, rpl)
|
|||
rb_ary_modify(ary);
|
||||
|
||||
if (beg >= RARRAY(ary)->len) {
|
||||
len = beg + rlen;
|
||||
if (len < 0 || len > ARY_MAX_SIZE) {
|
||||
if (beg > ARY_MAX_SIZE - rlen) {
|
||||
rb_raise(rb_eIndexError, "index %ld too big", beg);
|
||||
}
|
||||
len = beg + rlen;
|
||||
if (len >= RARRAY(ary)->aux.capa) {
|
||||
REALLOC_N(RARRAY(ary)->ptr, VALUE, len);
|
||||
RARRAY(ary)->aux.capa = len;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue