зеркало из https://github.com/github/ruby.git
string.c: negation of LONG_MIN
* string.c (rb_str_update): do not use negation of LONG_MIN, which is negative too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
f4d13801b6
Коммит
d69d98f61a
6
string.c
6
string.c
|
@ -4435,12 +4435,14 @@ rb_str_update(VALUE str, long beg, long len, VALUE val)
|
|||
rb_raise(rb_eIndexError, "index %ld out of string", beg);
|
||||
}
|
||||
if (beg < 0) {
|
||||
if (-beg > slen) {
|
||||
if (beg + slen < 0) {
|
||||
goto out_of_range;
|
||||
}
|
||||
beg += slen;
|
||||
}
|
||||
if (slen < len || slen < beg + len) {
|
||||
assert(beg >= 0);
|
||||
assert(beg <= slen);
|
||||
if (len > slen - beg) {
|
||||
len = slen - beg;
|
||||
}
|
||||
str_modify_keep_cr(str);
|
||||
|
|
|
@ -202,6 +202,8 @@ CODE
|
|||
assert_equal("fobar", s)
|
||||
|
||||
assert_raise(ArgumentError) { "foo"[1, 2, 3] = "" }
|
||||
|
||||
assert_raise(IndexError) {"foo"[RbConfig::Limits["LONG_MIN"]] = "l"}
|
||||
end
|
||||
|
||||
def test_CMP # '<=>'
|
||||
|
|
Загрузка…
Ссылка в новой задаче