mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-03 01:15:58 +00:00
SLUDGE: Fix Common::String operator[] out of range
This commit is contained in:
parent
7734cb937d
commit
02b09dc8fc
@ -75,11 +75,13 @@ Common::U32String UTF8Converter::convertUtf8ToUtf32(const Common::String &str) {
|
||||
|
||||
/* utf32 index => original byte offset */
|
||||
int UTF8Converter::getOriginOffset(int origIdx) {
|
||||
int offs = 0;
|
||||
|
||||
while (origIdx > 0 && _str[offs]) {
|
||||
uint offs = 0;
|
||||
while (origIdx > 0 && offs < _str.size()) {
|
||||
// increment if it's not the start of a utf8 sequence
|
||||
(void)(isutf(_str[++offs]) || isutf(_str[++offs]) || isutf(_str[++offs]) || ++offs);
|
||||
(void)( (++offs < _str.size() && isutf(_str[offs])) ||
|
||||
(++offs < _str.size() && isutf(_str[offs])) ||
|
||||
(++offs < _str.size() && isutf(_str[offs])) ||
|
||||
++offs);
|
||||
origIdx--;
|
||||
}
|
||||
return offs;
|
||||
|
Loading…
x
Reference in New Issue
Block a user