aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/ExpandableDictionary.java
diff options
context:
space:
mode:
authorSatoshi Kataoka <satok@google.com>2013-04-03 19:21:00 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-04-03 19:21:00 -0700
commit0c99a379bd7eca152fa600a6ab4c214482270625 (patch)
treef1c3038b728d17164adbc7da0089e9a5768df81a /java/src/com/android/inputmethod/latin/ExpandableDictionary.java
parent35e02ccdda43bb40cf95bca5ec0d96e55848d862 (diff)
parente42522f33566857402a8db645f58de2818456dc7 (diff)
downloadlatinime-0c99a379bd7eca152fa600a6ab4c214482270625.tar.gz
latinime-0c99a379bd7eca152fa600a6ab4c214482270625.tar.xz
latinime-0c99a379bd7eca152fa600a6ab4c214482270625.zip
am e42522f3: am 2cdf5351: Merge "Fix possible SIOOBE"
* commit 'e42522f33566857402a8db645f58de2818456dc7': Fix possible SIOOBE
Diffstat (limited to 'java/src/com/android/inputmethod/latin/ExpandableDictionary.java')
-rw-r--r--java/src/com/android/inputmethod/latin/ExpandableDictionary.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java
index ae2ee577f..fd81d13ca 100644
--- a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java
+++ b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java
@@ -18,6 +18,7 @@ package com.android.inputmethod.latin;
import android.content.Context;
import android.text.TextUtils;
+import android.util.Log;
import com.android.inputmethod.keyboard.ProximityInfo;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
@@ -31,6 +32,7 @@ import java.util.LinkedList;
* be searched for suggestions and valid words.
*/
public class ExpandableDictionary extends Dictionary {
+ private static final String TAG = ExpandableDictionary.class.getSimpleName();
/**
* The weight to give to a word if it's length is the same as the number of typed characters.
*/
@@ -551,8 +553,13 @@ public class ExpandableDictionary extends Dictionary {
// word. We do want however to return the correct case for the right hand side.
// So we want to squash the case of the left hand side, and preserve that of the right
// hand side word.
- Node firstWord = searchWord(mRoots, word1.toLowerCase(), 0, null);
- Node secondWord = searchWord(mRoots, word2, 0, null);
+ final String word1Lower = word1.toLowerCase();
+ if (TextUtils.isEmpty(word1Lower) || TextUtils.isEmpty(word2)) {
+ Log.e(TAG, "Invalid bigram pair: " + word1 + ", " + word1Lower + ", " + word2);
+ return frequency;
+ }
+ final Node firstWord = searchWord(mRoots, word1Lower, 0, null);
+ final Node secondWord = searchWord(mRoots, word2, 0, null);
LinkedList<NextWord> bigrams = firstWord.mNGrams;
if (bigrams == null || bigrams.size() == 0) {
firstWord.mNGrams = CollectionUtils.newLinkedList();