mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Fix OOB read in string::rfind
This commit is contained in:
parent
36f5fb5836
commit
1c78b63a7f
1 changed files with 2 additions and 3 deletions
|
|
@ -1061,11 +1061,10 @@ size_t String::rfind(String* str, size_t pos)
|
|||
if (srcStrLen == 0)
|
||||
return pos <= size ? pos : -1;
|
||||
if (srcStrLen <= size) {
|
||||
if (pos > size - srcStrLen)
|
||||
pos = size - srcStrLen;
|
||||
do {
|
||||
bool same = true;
|
||||
if (pos >= size) {
|
||||
continue;
|
||||
}
|
||||
for (size_t k = 0; k < srcStrLen; k++) {
|
||||
if (charAt(pos + k) != str->charAt(k)) {
|
||||
same = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue