Merge "Fix potential ArrayIndexOutOfBoundsException"

This commit is contained in:
Tadashi G. Takaoka 2011-09-08 23:24:20 -07:00 committed by Android (Google) Code Review
commit 530b4176c2

View File

@ -67,7 +67,10 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel {
@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