diff options
author | 2012-04-17 16:02:35 +0900 | |
---|---|---|
committer | 2012-04-17 16:57:42 +0900 | |
commit | ee396df162b31cff9763dd10a7da2b47aef10c01 (patch) | |
tree | 5a9825a6c3d3b0cad1c439d60d0dafb598ed8953 | |
parent | 12776925199fd969626c49674d78eaec8e5f9b43 (diff) | |
download | latinime-ee396df162b31cff9763dd10a7da2b47aef10c01.tar.gz latinime-ee396df162b31cff9763dd10a7da2b47aef10c01.tar.xz latinime-ee396df162b31cff9763dd10a7da2b47aef10c01.zip |
Fix a native crash
This was introduced by Ieb2e306a which failed to keep the return
behavior in case the word doesn't have a bigram.
Change-Id: I6d2f0b79d41c4335e94696690c8331e314961133
-rw-r--r-- | native/jni/src/bigram_dictionary.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/native/jni/src/bigram_dictionary.cpp b/native/jni/src/bigram_dictionary.cpp index 87ca1e9ed..ab739e144 100644 --- a/native/jni/src/bigram_dictionary.cpp +++ b/native/jni/src/bigram_dictionary.cpp @@ -109,6 +109,8 @@ int BigramDictionary::getBigrams(unsigned short *prevWord, int prevWordLength, i const uint8_t* const root = DICT; int pos = getBigramListForWord(root, prevWord, prevWordLength); + // getBigramListForWord returns 0 if this word is not in the dictionary or has no bigrams + if (0 == pos) return 0; int bigramFlags; int bigramCount = 0; do { @@ -130,6 +132,8 @@ int BigramDictionary::getBigrams(unsigned short *prevWord, int prevWordLength, i return bigramCount; } +// Returns a pointer to the start of the bigram list. +// If the word is not found or has no bigrams, this function returns 0. int BigramDictionary::getBigramListForWord(const uint8_t* const root, const unsigned short *prevWord, const int prevWordLength) { int pos = BinaryFormat::getTerminalPosition(root, prevWord, prevWordLength); |