summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/inputmethod
diff options
context:
space:
mode:
authorEric Fischer <enf@google.com>2010-03-08 16:38:03 -0800
committerEric Fischer <enf@google.com>2010-03-08 16:38:03 -0800
commit1127895fd42111f95fdc5049141c512e60198292 (patch)
tree9d527b7db0db85b7a501745a5d82ae65dc56d920 /core/java/android/view/inputmethod
parentb3871fad556084932b6d17d07972cd2d8250fb5c (diff)
downloadframeworks_base-1127895fd42111f95fdc5049141c512e60198292.zip
frameworks_base-1127895fd42111f95fdc5049141c512e60198292.tar.gz
frameworks_base-1127895fd42111f95fdc5049141c512e60198292.tar.bz2
Guard against calls to getTextAfterCursor() in text that has no cursor.
Act like the cursor is at 0 in this case instead of crashing. Bug 2497485 Change-Id: I5ce9b83b323d895e3be75e3133ff2f8e33cc203d
Diffstat (limited to 'core/java/android/view/inputmethod')
-rw-r--r--core/java/android/view/inputmethod/BaseInputConnection.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/core/java/android/view/inputmethod/BaseInputConnection.java b/core/java/android/view/inputmethod/BaseInputConnection.java
index 7393737..6ac1633 100644
--- a/core/java/android/view/inputmethod/BaseInputConnection.java
+++ b/core/java/android/view/inputmethod/BaseInputConnection.java
@@ -328,6 +328,11 @@ public class BaseInputConnection implements InputConnection {
b = tmp;
}
+ // Guard against the case where the cursor has not been positioned yet.
+ if (b < 0) {
+ b = 0;
+ }
+
if (b + length > content.length()) {
length = content.length() - b;
}