From 435cccb2c5869099be0fae07a103219410e3d2f1 Mon Sep 17 00:00:00 2001 From: Satoshi Kataoka Date: Tue, 26 Mar 2013 12:58:44 +0900 Subject: [PATCH] Fix Possible NPE Bug: 8448448 Change-Id: Ibe89c9abd24c4debb33a69c372eadf2afb09ea1c --- .../android/inputmethod/latin/UserHistoryDictIOUtils.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/UserHistoryDictIOUtils.java b/java/src/com/android/inputmethod/latin/UserHistoryDictIOUtils.java index 62f2a9750..10931555e 100644 --- a/java/src/com/android/inputmethod/latin/UserHistoryDictIOUtils.java +++ b/java/src/com/android/inputmethod/latin/UserHistoryDictIOUtils.java @@ -207,7 +207,12 @@ public final class UserHistoryDictIOUtils { final ArrayList attrList = bigrams.get(entry.getKey()); if (attrList != null) { for (final PendingAttribute attr : attrList) { - to.setBigram(word1, unigrams.get(attr.mAddress), + final String word2 = unigrams.get(attr.mAddress); + if (word1 == null || word2 == null) { + Log.e(TAG, "Invalid bigram pair detected: " + word1 + ", " + word2); + continue; + } + to.setBigram(word1, word2, BinaryDictInputOutput.reconstructBigramFrequency(unigramFrequency, attr.mFrequency)); }