am 3518ed60: Merge "Fix one-off bugs reported by Valgrind" into jb-mr1-dev
* commit '3518ed6031a1bcb9a501be4b9e1f5b82568185bd': Fix one-off bugs reported by Valgrindmain
commit
3f31e96362
|
@ -360,7 +360,7 @@ inline int BinaryFormat::getTerminalPosition(const uint8_t *const root,
|
||||||
while (true) {
|
while (true) {
|
||||||
// If we already traversed the tree further than the word is long, there means
|
// If we already traversed the tree further than the word is long, there means
|
||||||
// there was no match (or we would have found it).
|
// there was no match (or we would have found it).
|
||||||
if (wordPos > length) return NOT_VALID_WORD;
|
if (wordPos >= length) return NOT_VALID_WORD;
|
||||||
int charGroupCount = BinaryFormat::getGroupCountAndForwardPointer(root, &pos);
|
int charGroupCount = BinaryFormat::getGroupCountAndForwardPointer(root, &pos);
|
||||||
const int32_t wChar = forceLowerCaseSearch ? toLowerCase(inWord[wordPos]) : inWord[wordPos];
|
const int32_t wChar = forceLowerCaseSearch ? toLowerCase(inWord[wordPos]) : inWord[wordPos];
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -383,7 +383,7 @@ inline int BinaryFormat::getTerminalPosition(const uint8_t *const root,
|
||||||
// character that does not match, as explained above, it means the word is
|
// character that does not match, as explained above, it means the word is
|
||||||
// not in the dictionary (by virtue of this chargroup being the only one to
|
// not in the dictionary (by virtue of this chargroup being the only one to
|
||||||
// match the word on the first character, but not matching the whole word).
|
// match the word on the first character, but not matching the whole word).
|
||||||
if (wordPos > length) return NOT_VALID_WORD;
|
if (wordPos >= length) return NOT_VALID_WORD;
|
||||||
if (inWord[wordPos] != character) return NOT_VALID_WORD;
|
if (inWord[wordPos] != character) return NOT_VALID_WORD;
|
||||||
character = BinaryFormat::getCodePointAndForwardPointer(root, &pos);
|
character = BinaryFormat::getCodePointAndForwardPointer(root, &pos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,7 +451,7 @@ int UnigramDictionary::getSubStringSuggestion(
|
||||||
const bool hasAutoCorrectionCandidate, const int currentWordIndex,
|
const bool hasAutoCorrectionCandidate, const int currentWordIndex,
|
||||||
const int inputWordStartPos, const int inputWordLength,
|
const int inputWordStartPos, const int inputWordLength,
|
||||||
const int outputWordStartPos, const bool isSpaceProximity, int *freqArray,
|
const int outputWordStartPos, const bool isSpaceProximity, int *freqArray,
|
||||||
int*wordLengthArray, unsigned short *outputWord, int *outputWordLength) const {
|
int *wordLengthArray, unsigned short *outputWord, int *outputWordLength) const {
|
||||||
if (inputWordLength > MULTIPLE_WORDS_SUGGESTION_MAX_WORD_LENGTH) {
|
if (inputWordLength > MULTIPLE_WORDS_SUGGESTION_MAX_WORD_LENGTH) {
|
||||||
return FLAG_MULTIPLE_SUGGEST_ABORT;
|
return FLAG_MULTIPLE_SUGGEST_ABORT;
|
||||||
}
|
}
|
||||||
|
@ -546,9 +546,9 @@ int UnigramDictionary::getSubStringSuggestion(
|
||||||
freq = score >> (nextWordLength + TWO_WORDS_PLUS_OTHER_ERROR_CORRECTION_DEMOTION_DIVIDER);
|
freq = score >> (nextWordLength + TWO_WORDS_PLUS_OTHER_ERROR_CORRECTION_DEMOTION_DIVIDER);
|
||||||
}
|
}
|
||||||
if (DEBUG_DICT) {
|
if (DEBUG_DICT) {
|
||||||
AKLOGI("Freq(%d): %d, length: %d, input length: %d, input start: %d (%d)"
|
AKLOGI("Freq(%d): %d, length: %d, input length: %d, input start: %d (%d)",
|
||||||
, currentWordIndex, freq, nextWordLength, inputWordLength, inputWordStartPos,
|
currentWordIndex, freq, nextWordLength, inputWordLength, inputWordStartPos,
|
||||||
wordLengthArray[0]);
|
(currentWordIndex > 0) ? wordLengthArray[0] : 0);
|
||||||
}
|
}
|
||||||
if (freq <= 0 || nextWordLength <= 0
|
if (freq <= 0 || nextWordLength <= 0
|
||||||
|| MAX_WORD_LENGTH <= (outputWordStartPos + nextWordLength)) {
|
|| MAX_WORD_LENGTH <= (outputWordStartPos + nextWordLength)) {
|
||||||
|
|
Loading…
Reference in New Issue