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

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:
nobu 2017-03-07 09:13:41 +00:00
parent f4d13801b6
commit d69d98f61a
2 changed files with 6 additions and 2 deletions

View file

@ -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);

View file

@ -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 # '<=>'