fix: custom spell-checker stuck in infinite loop (#45001)
`ReadUnicodeCharacter` updates index to the last character read, and not after it. We need to manually increment it to move to the next character. It also doesn't validate that the index is valid, so we need to check that index is within bounds. Refs: #44336
This commit is contained in:
		
					parent
					
						
							
								be1a3dce83
							
						
					
				
			
			
				commit
				
					
						e2e71502b1
					
				
			
		
					 1 changed files with 3 additions and 1 deletions
				
			
		| 
						 | 
					@ -32,7 +32,9 @@ namespace {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool HasWordCharacters(const std::u16string& text, size_t index) {
 | 
					bool HasWordCharacters(const std::u16string& text, size_t index) {
 | 
				
			||||||
  base_icu::UChar32 code;
 | 
					  base_icu::UChar32 code;
 | 
				
			||||||
  while (base::ReadUnicodeCharacter(text.c_str(), text.size(), &index, &code)) {
 | 
					  while (index < text.size() &&
 | 
				
			||||||
 | 
					         base::ReadUnicodeCharacter(text.c_str(), text.size(), &index, &code)) {
 | 
				
			||||||
 | 
					    ++index;
 | 
				
			||||||
    UErrorCode error = U_ZERO_ERROR;
 | 
					    UErrorCode error = U_ZERO_ERROR;
 | 
				
			||||||
    if (uscript_getScript(code, &error) != USCRIPT_COMMON)
 | 
					    if (uscript_getScript(code, &error) != USCRIPT_COMMON)
 | 
				
			||||||
      return true;
 | 
					      return true;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue