diff options
author | 2010-12-06 21:28:24 +0900 | |
---|---|---|
committer | 2010-12-06 22:58:56 +0900 | |
commit | f5cded1c6cf0f39df13750d4f9f5ba66c1b32964 (patch) | |
tree | 36b85632d436e00fbce2ca31c5ac7170e70abadf /java/src/com/android/inputmethod/latin/BinaryDictionary.java | |
parent | 48e432ceb830c1932bd4f52d5fd2780b94685bf7 (diff) | |
download | latinime-f5cded1c6cf0f39df13750d4f9f5ba66c1b32964.tar.gz latinime-f5cded1c6cf0f39df13750d4f9f5ba66c1b32964.tar.xz latinime-f5cded1c6cf0f39df13750d4f9f5ba66c1b32964.zip |
Fix a crash when MAX_WORD_LENGTH is too short.
Change-Id: Idcb5aa2685321b8d0ac7d846caecbd1c79e4dd77
Diffstat (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionary.java')
-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, |