From 5955cfdaeae9ce2120769a4be965bdbac413bf79 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 9 Sep 2011 18:08:53 +0900 Subject: [PATCH] Fix an NPE I think only the monkey can realistically stumble on this one, but still. Bug: 5276917 Change-Id: I0d9f76e4786973d3695fcd46127f0bed46621c33 --- .../android/inputmethod/latin/LatinIME.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 08af5c5e3..843185181 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1872,14 +1872,16 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return; } - final boolean selectedATypedWordAndItsInUserUnigramDic = - !selectedANotTypedWord && mUserUnigramDictionary.isValidWord(suggestion); - final boolean isValidWord = AutoCorrection.isValidWord( - mSuggest.getUnigramDictionaries(), suggestion, true); - final boolean needsToAddToUserUnigramDictionary = selectedATypedWordAndItsInUserUnigramDic - || !isValidWord; - if (needsToAddToUserUnigramDictionary) { - mUserUnigramDictionary.addWord(suggestion.toString(), frequencyDelta); + if (null != mSuggest && null != mUserUnigramDictionary) { + final boolean selectedATypedWordAndItsInUserUnigramDic = + !selectedANotTypedWord && mUserUnigramDictionary.isValidWord(suggestion); + final boolean isValidWord = AutoCorrection.isValidWord( + mSuggest.getUnigramDictionaries(), suggestion, true); + final boolean needsToAddToUserUnigramDictionary = + selectedATypedWordAndItsInUserUnigramDic || !isValidWord; + if (needsToAddToUserUnigramDictionary) { + mUserUnigramDictionary.addWord(suggestion.toString(), frequencyDelta); + } } if (mUserBigramDictionary != null) {