diff options
| author | Simei Yin | 2017-08-12 11:42:04 +0200 | 
|---|---|---|
| committer | Simei Yin | 2017-08-12 11:42:04 +0200 | 
| commit | 02b09dc8fc7716e587d2120dd0674a492d3a6eb3 (patch) | |
| tree | 64aa818c730af7c156b54feda5e80055e1164f94 | |
| parent | 7734cb937df59048d5538b43751b2e50dd56b62f (diff) | |
| download | scummvm-rg350-02b09dc8fc7716e587d2120dd0674a492d3a6eb3.tar.gz scummvm-rg350-02b09dc8fc7716e587d2120dd0674a492d3a6eb3.tar.bz2 scummvm-rg350-02b09dc8fc7716e587d2120dd0674a492d3a6eb3.zip  | |
SLUDGE: Fix Common::String operator[] out of range
| -rw-r--r-- | engines/sludge/utf8.cpp | 10 | 
1 files changed, 6 insertions, 4 deletions
diff --git a/engines/sludge/utf8.cpp b/engines/sludge/utf8.cpp index 61c297571b..bfcaec5ab9 100644 --- a/engines/sludge/utf8.cpp +++ b/engines/sludge/utf8.cpp @@ -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;  | 
