diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-07 09:13:41 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-07 09:13:41 +0000 |
commit | 11f74964bc72c235b01fd0018083d41b8c988339 (patch) | |
tree | f275f03d35b08e67be82c7c18a3ba9d8d2d09466 /string.c | |
parent | 7017320f8bac809918117ffd4cf4f76e19fcf06c (diff) | |
download | ruby-11f74964bc72c235b01fd0018083d41b8c988339.tar.gz |
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
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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); |