am 7852765a: Add length check for attaching a BoS marker.

* commit '7852765a503fe6dab54e1c4ab9e5e6b7bbdc70f2':
  Add length check for attaching a BoS marker.
main
Keisuke Kuroyanagi 2014-05-28 11:32:01 +00:00 committed by Android Git Automerger
commit eeea786fb3
1 changed files with 4 additions and 1 deletions

View File

@ -92,7 +92,7 @@ class PrevWordsInfo {
const DictionaryStructureWithBufferPolicy *const dictStructurePolicy, const DictionaryStructureWithBufferPolicy *const dictStructurePolicy,
const int *const wordCodePoints, const int wordCodePointCount, const int *const wordCodePoints, const int wordCodePointCount,
const bool isBeginningOfSentence, const bool tryLowerCaseSearch) { const bool isBeginningOfSentence, const bool tryLowerCaseSearch) {
if (!dictStructurePolicy || !wordCodePoints) { if (!dictStructurePolicy || !wordCodePoints || wordCodePointCount > MAX_WORD_LENGTH) {
return NOT_A_DICT_POS; return NOT_A_DICT_POS;
} }
int codePoints[MAX_WORD_LENGTH]; int codePoints[MAX_WORD_LENGTH];
@ -122,6 +122,9 @@ class PrevWordsInfo {
const DictionaryStructureWithBufferPolicy *const dictStructurePolicy, const DictionaryStructureWithBufferPolicy *const dictStructurePolicy,
const int *const wordCodePoints, const int wordCodePointCount, const int *const wordCodePoints, const int wordCodePointCount,
const bool isBeginningOfSentence) { const bool isBeginningOfSentence) {
if (!dictStructurePolicy || !wordCodePoints || wordCodePointCount > MAX_WORD_LENGTH) {
return NOT_A_DICT_POS;
}
int codePoints[MAX_WORD_LENGTH]; int codePoints[MAX_WORD_LENGTH];
int codePointCount = wordCodePointCount; int codePointCount = wordCodePointCount;
memmove(codePoints, wordCodePoints, sizeof(int) * codePointCount); memmove(codePoints, wordCodePoints, sizeof(int) * codePointCount);