string.c: fix integer overflow
* string.c (rb_str_subpos): fix integer overflow which can happen only when SHARABLE_MIDDLE_SUBSTRING is enabled. incorpolate https://github.com/mruby/mruby/commit/7db0786abdd243ba031e24683f git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a298301baa
commit
72f8df158f
2
string.c
2
string.c
@ -2386,7 +2386,7 @@ rb_str_subpos(VALUE str, long beg, long *lenp)
|
|||||||
beg += blen;
|
beg += blen;
|
||||||
if (beg < 0) return 0;
|
if (beg < 0) return 0;
|
||||||
}
|
}
|
||||||
if (beg + len > blen)
|
if (len > blen - beg)
|
||||||
len = blen - beg;
|
len = blen - beg;
|
||||||
if (len < 0) return 0;
|
if (len < 0) return 0;
|
||||||
p = s + beg;
|
p = s + beg;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user