diff options
author | 2014-08-29 19:07:03 +0000 | |
---|---|---|
committer | 2014-08-29 19:07:03 +0000 | |
commit | 78bb2dd945a013f230396f3ce9c122a20fec21cf (patch) | |
tree | d9aaa5086cf24eab8513f27abaf27c6103deeca8 | |
parent | f9af39e53edbf6c466c46d2a3111e28f72acaf34 (diff) | |
parent | 3bd8eee3e8c3e89539578a4231661819de65c804 (diff) | |
download | latinime-78bb2dd945a013f230396f3ce9c122a20fec21cf.tar.gz latinime-78bb2dd945a013f230396f3ce9c122a20fec21cf.tar.xz latinime-78bb2dd945a013f230396f3ce9c122a20fec21cf.zip |
am 3bd8eee3: am 4e28a6a8: Fix an IOOB exception
* commit '3bd8eee3e8c3e89539578a4231661819de65c804':
Fix an IOOB exception
-rw-r--r-- | java/src/com/android/inputmethod/latin/SuggestedWords.java | 2 | ||||
-rw-r--r-- | tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index 1eebabece..6bc3da885 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -429,7 +429,7 @@ public class SuggestedWords { */ @UsedForTesting public SuggestedWordInfo getTypedWordInfoOrNull() { - if (this == EMPTY) { + if (SuggestedWords.INDEX_OF_TYPED_WORD >= size()) { return null; } final SuggestedWordInfo info = getInfo(SuggestedWords.INDEX_OF_TYPED_WORD); diff --git a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java index c28d08cdb..869c550e0 100644 --- a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java +++ b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java @@ -148,5 +148,15 @@ public class SuggestedWordsTests extends AndroidTestCase { // Make sure getTypedWordInfoOrNull() returns null. assertNull(SuggestedWords.EMPTY.getTypedWordInfoOrNull()); + + final SuggestedWords emptySuggestedWords = new SuggestedWords( + new ArrayList<SuggestedWordInfo>(), null /* rawSuggestions */, + false /* typedWordValid */, + false /* willAutoCorrect */, + false /* isObsoleteSuggestions */, + SuggestedWords.INPUT_STYLE_NONE); + assertNull(emptySuggestedWords.getTypedWordInfoOrNull()); + + assertNull(SuggestedWords.EMPTY.getTypedWordInfoOrNull()); } } |