Skip to content

Commit c08ec61

Browse files
author
Gilles Debunne
committed
Bug 5385279: IOOB in createMisspelledSuggestionSpan
Race condition: when spell check result come back, the spell check span may no longer be in the text, although it should have been removed by removeSpellCheckSpan. This is possible because onGetSuggestions is called from an other thread and it can see the text in an inconsistent state where the span may have been removed from the text, but the listener that calls removeSpellCheckSpan has not yet been called. As a result, onGetSuggestions still lists the span but getSpanStart returns -1. Change-Id: Ia40f7ed2b46fc94888fce5a6b209fb0d0d529bbe
1 parent 1eb08f0 commit c08ec61

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

core/java/android/widget/SpellChecker.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ private void createMisspelledSuggestionSpan(Editable editable,
239239
SuggestionsInfo suggestionsInfo, SpellCheckSpan spellCheckSpan) {
240240
final int start = editable.getSpanStart(spellCheckSpan);
241241
final int end = editable.getSpanEnd(spellCheckSpan);
242+
if (start < 0 || end < 0) return; // span was removed in the meantime
242243

243244
// Other suggestion spans may exist on that region, with identical suggestions, filter
244245
// them out to avoid duplicates. First, filter suggestion spans on that exact region.

0 commit comments

Comments
 (0)