From f6f0e63d79eabcd4f0cce9d697066028aed2f00a Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 22 Jul 2011 14:46:43 +0900 Subject: [PATCH] Do not register null pointers as dictionaries Bug: 5062425 Change-Id: I025991424de40c2b31b90238f99ef160e7efd92e --- .../com/android/inputmethod/latin/DictionaryCollection.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/DictionaryCollection.java b/java/src/com/android/inputmethod/latin/DictionaryCollection.java index e987d9f0c..107840331 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryCollection.java +++ b/java/src/com/android/inputmethod/latin/DictionaryCollection.java @@ -17,6 +17,7 @@ package com.android.inputmethod.latin; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -36,11 +37,13 @@ public class DictionaryCollection extends Dictionary { mDictionaries = new CopyOnWriteArrayList(); } else { mDictionaries = new CopyOnWriteArrayList(dictionaries); + mDictionaries.removeAll(Collections.singleton(null)); } } public DictionaryCollection(Collection dictionaries) { mDictionaries = new CopyOnWriteArrayList(dictionaries); + mDictionaries.removeAll(Collections.singleton(null)); } @Override @@ -70,6 +73,6 @@ public class DictionaryCollection extends Dictionary { } public void addDictionary(Dictionary newDict) { - mDictionaries.add(newDict); + if (null != newDict) mDictionaries.add(newDict); } }