diff options
author | 2010-12-06 20:06:03 -0800 | |
---|---|---|
committer | 2010-12-06 20:06:03 -0800 | |
commit | e00b7c5f7bb4058a67487b6bec664d319cf25f08 (patch) | |
tree | cc135ac847c5978458edbea6e58c26dd6ad33c3b /java/src | |
parent | 292faee8ba73797c8a97052c02f9b571cfb128b3 (diff) | |
parent | f5cded1c6cf0f39df13750d4f9f5ba66c1b32964 (diff) | |
download | latinime-e00b7c5f7bb4058a67487b6bec664d319cf25f08.tar.gz latinime-e00b7c5f7bb4058a67487b6bec664d319cf25f08.tar.xz latinime-e00b7c5f7bb4058a67487b6bec664d319cf25f08.zip |
Merge "Fix a crash when MAX_WORD_LENGTH is too short."
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/BinaryDictionary.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index c7f629f15..961b49f02 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -170,12 +170,12 @@ public class BinaryDictionary extends Dictionary { mOutputChars_bigrams, mFrequencies_bigrams, MAX_WORD_LENGTH, MAX_BIGRAMS, MAX_ALTERNATIVES); - for (int j = 0; j < count; j++) { + for (int j = 0; j < count; ++j) { if (mFrequencies_bigrams[j] < 1) break; - int start = j * MAX_WORD_LENGTH; + final int start = j * MAX_WORD_LENGTH; int len = 0; - while (mOutputChars_bigrams[start + len] != 0) { - len++; + while (len < MAX_WORD_LENGTH && mOutputChars_bigrams[start + len] != 0) { + ++len; } if (len > 0) { callback.addWord(mOutputChars_bigrams, start, len, mFrequencies_bigrams[j], @@ -204,12 +204,12 @@ public class BinaryDictionary extends Dictionary { mFrequencies, nextLettersFrequencies, nextLettersFrequencies != null ? nextLettersFrequencies.length : 0); - for (int j = 0; j < count; j++) { + for (int j = 0; j < count; ++j) { if (mFrequencies[j] < 1) break; - int start = j * MAX_WORD_LENGTH; + final int start = j * MAX_WORD_LENGTH; int len = 0; - while (mOutputChars[start + len] != 0) { - len++; + while (len < MAX_WORD_LENGTH && mOutputChars[start + len] != 0) { + ++len; } if (len > 0) { callback.addWord(mOutputChars, start, len, mFrequencies[j], mDicTypeId, |