diff options
author | Yohei Yukawa <yukawa@google.com> | 2014-01-17 08:59:07 +0900 |
---|---|---|
committer | Yohei Yukawa <yukawa@google.com> | 2014-01-17 09:59:25 +0900 |
commit | ef0904106d09a5471f809feec4219dc22fc740fe (patch) | |
tree | 0769fb967a7f81418f70f38c04594b572c4f55b3 /core/java/android/view/inputmethod | |
parent | 432005306dc26fcd613ca75b6bfca6c84fc96dcd (diff) | |
download | frameworks_base-ef0904106d09a5471f809feec4219dc22fc740fe.zip frameworks_base-ef0904106d09a5471f809feec4219dc22fc740fe.tar.gz frameworks_base-ef0904106d09a5471f809feec4219dc22fc740fe.tar.bz2 |
Make the range checking of BaseInputConnection#setSelection stricter
With this change, setSelection will not cause java.lang.IndexOutOfBoundsException
even if a negative index is specified.
Bug: 8841916
Change-Id: Ib62a6ba235f80b7495fefb2e5cc2d5357d804310
Diffstat (limited to 'core/java/android/view/inputmethod')
-rw-r--r-- | core/java/android/view/inputmethod/BaseInputConnection.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/java/android/view/inputmethod/BaseInputConnection.java b/core/java/android/view/inputmethod/BaseInputConnection.java index 5552952..cccfa78 100644 --- a/core/java/android/view/inputmethod/BaseInputConnection.java +++ b/core/java/android/view/inputmethod/BaseInputConnection.java @@ -484,10 +484,10 @@ public class BaseInputConnection implements InputConnection { final Editable content = getEditable(); if (content == null) return false; int len = content.length(); - if (start > len || end > len) { + if (start > len || end > len || start < 0 || end < 0) { // If the given selection is out of bounds, just ignore it. // Most likely the text was changed out from under the IME, - // the the IME is going to have to update all of its state + // and the IME is going to have to update all of its state // anyway. return true; } |