Skip to content

Commit a200a23

Browse files
Fabrice Di MeglioAndroid (Google) Code Review
authored andcommitted
Merge "Bug 5332065: IOOB in case the suggestionSpan has been removed" into ics-factoryrom
2 parents 8632561 + 14ed50a commit a200a23

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/java/android/widget/TextView.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9879,13 +9879,16 @@ private void highlightTextDifferences(SuggestionInfo suggestionInfo, int unionSt
98799879

98809880
@Override
98819881
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
9882+
hide();
9883+
98829884
if (view instanceof TextView) {
98839885
TextView textView = (TextView) view;
98849886
Editable editable = (Editable) mText;
98859887

98869888
SuggestionInfo suggestionInfo = mSuggestionInfos[position];
98879889
final int spanStart = editable.getSpanStart(suggestionInfo.suggestionSpan);
98889890
final int spanEnd = editable.getSpanEnd(suggestionInfo.suggestionSpan);
9891+
if (spanStart < 0 || spanEnd < 0) return; // Span has been removed
98899892
final String originalText = mText.subSequence(spanStart, spanEnd).toString();
98909893

98919894
if (suggestionInfo.suggestionIndex < 0) {
@@ -9947,7 +9950,6 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
99479950
Selection.setSelection(editable, spanEnd + lengthDifference);
99489951
}
99499952
}
9950-
hide();
99519953
}
99529954
}
99539955

0 commit comments

Comments
 (0)