diff options
author | 2012-08-03 22:47:17 +0900 | |
---|---|---|
committer | 2012-08-03 23:10:47 +0900 | |
commit | 4c976aceeef7238cabbbb29f5793b4e805d087e5 (patch) | |
tree | 29be39325d6f509e7dae55e2651fe7c805ec5689 /java/src/com/android/inputmethod/latin/ExpandableDictionary.java | |
parent | 77e8e81ad95cfc1eb8f8407fc872674b8d08bbe9 (diff) | |
download | latinime-4c976aceeef7238cabbbb29f5793b4e805d087e5.tar.gz latinime-4c976aceeef7238cabbbb29f5793b4e805d087e5.tar.xz latinime-4c976aceeef7238cabbbb29f5793b4e805d087e5.zip |
Fix an OOB exception
Not sure exactly how this can happen, but at least this should
prevent us from crashing.
Bug: 6920884
Change-Id: I451864756b48c5cb5e98b06edee917d88766d77f
Diffstat (limited to 'java/src/com/android/inputmethod/latin/ExpandableDictionary.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/ExpandableDictionary.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java index 5d7995dc2..d101aaf15 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java @@ -654,9 +654,12 @@ public class ExpandableDictionary extends Dictionary { --index; mLookedUpString[index] = node.mCode; node = node.mParent; - } while (node != null); + } while (node != null && index > 0); - if (freq >= 0) { + // If node is null, we have a word longer than MAX_WORD_LENGTH in the dictionary. + // It's a little unclear how this can happen, but just in case it does it's safer + // to ignore the word in this case. + if (freq >= 0 && node == null) { suggestions.add(new SuggestedWordInfo(new String(mLookedUpString, index, BinaryDictionary.MAX_WORD_LENGTH - index), freq, SuggestedWordInfo.KIND_CORRECTION, mDictType)); |