Fix Possible NPE

Bug: 8448448
Change-Id: Ibe89c9abd24c4debb33a69c372eadf2afb09ea1c
main
Satoshi Kataoka 2013-03-26 12:58:44 +09:00
parent 0b3271010f
commit 435cccb2c5
1 changed files with 6 additions and 1 deletions

View File

@ -207,7 +207,12 @@ public final class UserHistoryDictIOUtils {
final ArrayList<PendingAttribute> 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));
}