Fix potential ArrayIndexOutOfBoundsException

Change-Id: I5dad81fb274cbbcf2c4f106825eecf8e4903461c
diff --git a/java/src/com/android/inputmethod/latin/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/MoreSuggestionsView.java
index f595510..a5ff533 100644
--- a/java/src/com/android/inputmethod/latin/MoreSuggestionsView.java
+++ b/java/src/com/android/inputmethod/latin/MoreSuggestionsView.java
@@ -67,7 +67,10 @@
 
         @Override
         public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {
-            mListener.onCustomRequest(primaryCode - MoreSuggestions.SUGGESTION_CODE_BASE);
+            final int index = primaryCode - MoreSuggestions.SUGGESTION_CODE_BASE;
+            if (index >= 0 && index < SuggestionsView.MAX_SUGGESTIONS) {
+                mListener.onCustomRequest(index);
+            }
         }
 
         @Override