string.c: fix integer overflow
* string.c (str_byte_substr): fix another integer overflow which can happen only when SHARABLE_MIDDLE_SUBSTRING is enabled. [ruby-core:79951] [Bug #13289] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d19d629eaa
commit
f4d13801b6
2
string.c
2
string.c
@ -5254,7 +5254,7 @@ str_byte_substr(VALUE str, long beg, long len, int empty)
|
|||||||
beg += n;
|
beg += n;
|
||||||
if (beg < 0) return Qnil;
|
if (beg < 0) return Qnil;
|
||||||
}
|
}
|
||||||
if (beg + len > n)
|
if (len > n - beg)
|
||||||
len = n - beg;
|
len = n - beg;
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
if (!empty) return Qnil;
|
if (!empty) return Qnil;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user