From 81115075d28e7df6b43fd2252b83211ba2a827de Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Mon, 3 Aug 2009 17:47:44 -0700 Subject: [PATCH] Fix a stack overflow when typing long words. Limit the size of auto-added words. --- src/com/android/inputmethod/latin/LatinIME.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/com/android/inputmethod/latin/LatinIME.java b/src/com/android/inputmethod/latin/LatinIME.java index 222e0c5a2..4113d9b2c 100644 --- a/src/com/android/inputmethod/latin/LatinIME.java +++ b/src/com/android/inputmethod/latin/LatinIME.java @@ -1169,6 +1169,9 @@ public class LatinIME extends InputMethodService @Override public void addWord(String word, int addFrequency) { + final int length = word.length(); + // Don't add very short or very long words. + if (length < 2 || length > getMaxWordLength()) return; super.addWord(word, addFrequency); final int freq = getWordFrequency(word); if (freq > PROMOTION_THRESHOLD) {