Merge "Fix a bug of the conversion of the correction algorithm"
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index b197c5b..4d569b8 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -156,6 +156,11 @@
                 // }
                 return true;
             }
+            if (insertIndex >= mMaxLength) {
+                // We found a suggestion, but its score is too weak to be kept considering
+                // the suggestion limit.
+                return true;
+            }
 
             // Compute the normalized score and skip this word if it's normalized score does not
             // make the threshold.
@@ -438,8 +443,10 @@
                     Log.i(TAG, "IsInDict = " + isInDict);
                     Log.i(TAG, "LooksLikeTypo = " + (!isInDict));
                     Log.i(TAG, "HasLikelySuggestions = " + result.mHasLikelySuggestions);
-                    for (String suggestion : result.mSuggestions) {
-                        Log.i(TAG, suggestion);
+                    if (null != result.mSuggestions) {
+                        for (String suggestion : result.mSuggestions) {
+                            Log.i(TAG, suggestion);
+                        }
                     }
                 }