diff options
author | 2012-09-06 09:12:31 -0700 | |
---|---|---|
committer | 2012-09-06 09:12:31 -0700 | |
commit | 59e20c987aad8d07e7001fa684e3de8d8b57ca26 (patch) | |
tree | 17cce6b77a81e7eb1a1a475607092c7ed384c380 | |
parent | e0fef5067d82fad19f56e01a708fd881051b14a7 (diff) | |
parent | 3f31e96362a38e090a822b36b1de788a1ee04ed2 (diff) | |
download | latinime-59e20c987aad8d07e7001fa684e3de8d8b57ca26.tar.gz latinime-59e20c987aad8d07e7001fa684e3de8d8b57ca26.tar.xz latinime-59e20c987aad8d07e7001fa684e3de8d8b57ca26.zip |
am 3f31e963: am 3518ed60: Merge "Fix one-off bugs reported by Valgrind" into jb-mr1-dev
* commit '3f31e96362a38e090a822b36b1de788a1ee04ed2':
Fix one-off bugs reported by Valgrind
-rw-r--r-- | native/jni/src/binary_format.h | 4 | ||||
-rw-r--r-- | native/jni/src/unigram_dictionary.cpp | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/native/jni/src/binary_format.h b/native/jni/src/binary_format.h index 5d8b2a0f2..eec52e323 100644 --- a/native/jni/src/binary_format.h +++ b/native/jni/src/binary_format.h @@ -360,7 +360,7 @@ inline int BinaryFormat::getTerminalPosition(const uint8_t *const root, while (true) { // If we already traversed the tree further than the word is long, there means // 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); const int32_t wChar = forceLowerCaseSearch ? toLowerCase(inWord[wordPos]) : inWord[wordPos]; 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 // 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). - if (wordPos > length) return NOT_VALID_WORD; + if (wordPos >= length) return NOT_VALID_WORD; if (inWord[wordPos] != character) return NOT_VALID_WORD; character = BinaryFormat::getCodePointAndForwardPointer(root, &pos); } diff --git a/native/jni/src/unigram_dictionary.cpp b/native/jni/src/unigram_dictionary.cpp index b7e245a6c..cf806c111 100644 --- a/native/jni/src/unigram_dictionary.cpp +++ b/native/jni/src/unigram_dictionary.cpp @@ -451,7 +451,7 @@ int UnigramDictionary::getSubStringSuggestion( const bool hasAutoCorrectionCandidate, const int currentWordIndex, const int inputWordStartPos, const int inputWordLength, 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) { return FLAG_MULTIPLE_SUGGEST_ABORT; } @@ -546,9 +546,9 @@ int UnigramDictionary::getSubStringSuggestion( freq = score >> (nextWordLength + TWO_WORDS_PLUS_OTHER_ERROR_CORRECTION_DEMOTION_DIVIDER); } if (DEBUG_DICT) { - AKLOGI("Freq(%d): %d, length: %d, input length: %d, input start: %d (%d)" - , currentWordIndex, freq, nextWordLength, inputWordLength, inputWordStartPos, - wordLengthArray[0]); + AKLOGI("Freq(%d): %d, length: %d, input length: %d, input start: %d (%d)", + currentWordIndex, freq, nextWordLength, inputWordLength, inputWordStartPos, + (currentWordIndex > 0) ? wordLengthArray[0] : 0); } if (freq <= 0 || nextWordLength <= 0 || MAX_WORD_LENGTH <= (outputWordStartPos + nextWordLength)) { |