Skip to content
Snippets Groups Projects
Commit 4c976ace authored by Jean Chalard's avatar Jean Chalard
Browse files

Fix an OOB exception

Not sure exactly how this can happen, but at least this should
prevent us from crashing.

Bug: 6920884
Change-Id: I451864756b48c5cb5e98b06edee917d88766d77f
parent 77e8e81a
No related branches found
No related tags found
No related merge requests found
...@@ -654,9 +654,12 @@ public class ExpandableDictionary extends Dictionary { ...@@ -654,9 +654,12 @@ public class ExpandableDictionary extends Dictionary {
--index; --index;
mLookedUpString[index] = node.mCode; mLookedUpString[index] = node.mCode;
node = node.mParent; node = node.mParent;
} while (node != null); } while (node != null && index > 0);
if (freq >= 0) { // If node is null, we have a word longer than MAX_WORD_LENGTH in the dictionary.
// It's a little unclear how this can happen, but just in case it does it's safer
// to ignore the word in this case.
if (freq >= 0 && node == null) {
suggestions.add(new SuggestedWordInfo(new String(mLookedUpString, index, suggestions.add(new SuggestedWordInfo(new String(mLookedUpString, index,
BinaryDictionary.MAX_WORD_LENGTH - index), BinaryDictionary.MAX_WORD_LENGTH - index),
freq, SuggestedWordInfo.KIND_CORRECTION, mDictType)); freq, SuggestedWordInfo.KIND_CORRECTION, mDictType));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment