From f5cded1c6cf0f39df13750d4f9f5ba66c1b32964 Mon Sep 17 00:00:00 2001 From: satok Date: Mon, 6 Dec 2010 21:28:24 +0900 Subject: Fix a crash when MAX_WORD_LENGTH is too short. Change-Id: Idcb5aa2685321b8d0ac7d846caecbd1c79e4dd77 --- .../com/android/inputmethod/latin/BinaryDictionary.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'java/src') 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, -- cgit v1.2.3-83-g751a