am 63155dfa: Merge "Fix possible SIGSEGV."
* commit '63155dfa7782b314d18bc8f1a95440b1470838fe': Fix possible SIGSEGV.main
commit
cf0ae8aace
|
@ -49,8 +49,10 @@ class DicNodeStateOutput {
|
||||||
void addMergedNodeCodePoints(const uint16_t mergedNodeCodePointCount,
|
void addMergedNodeCodePoints(const uint16_t mergedNodeCodePointCount,
|
||||||
const int *const mergedNodeCodePoints) {
|
const int *const mergedNodeCodePoints) {
|
||||||
if (mergedNodeCodePoints) {
|
if (mergedNodeCodePoints) {
|
||||||
|
const int additionalCodePointCount = min(static_cast<int>(mergedNodeCodePointCount),
|
||||||
|
MAX_WORD_LENGTH - mOutputtedCodePointCount);
|
||||||
memcpy(&mCodePointsBuf[mOutputtedCodePointCount], mergedNodeCodePoints,
|
memcpy(&mCodePointsBuf[mOutputtedCodePointCount], mergedNodeCodePoints,
|
||||||
mergedNodeCodePointCount * sizeof(mCodePointsBuf[0]));
|
additionalCodePointCount * sizeof(mCodePointsBuf[0]));
|
||||||
mOutputtedCodePointCount = static_cast<uint16_t>(
|
mOutputtedCodePointCount = static_cast<uint16_t>(
|
||||||
mOutputtedCodePointCount + mergedNodeCodePointCount);
|
mOutputtedCodePointCount + mergedNodeCodePointCount);
|
||||||
if (mOutputtedCodePointCount < MAX_WORD_LENGTH) {
|
if (mOutputtedCodePointCount < MAX_WORD_LENGTH) {
|
||||||
|
|
|
@ -69,11 +69,14 @@ class DicNodeStatePrevWord {
|
||||||
const int prevWordNodePos, const int *const src0, const int16_t length0,
|
const int prevWordNodePos, const int *const src0, const int16_t length0,
|
||||||
const int *const src1, const int16_t length1, const int *const prevSpacePositions,
|
const int *const src1, const int16_t length1, const int *const prevSpacePositions,
|
||||||
const int lastInputIndex) {
|
const int lastInputIndex) {
|
||||||
mPrevWordCount = prevWordCount;
|
mPrevWordCount = min(prevWordCount, static_cast<int16_t>(MAX_RESULTS));
|
||||||
mPrevWordProbability = prevWordProbability;
|
mPrevWordProbability = prevWordProbability;
|
||||||
mPrevWordNodePos = prevWordNodePos;
|
mPrevWordNodePos = prevWordNodePos;
|
||||||
const int twoWordsLen =
|
int twoWordsLen =
|
||||||
DicNodeUtils::appendTwoWords(src0, length0, src1, length1, mPrevWord);
|
DicNodeUtils::appendTwoWords(src0, length0, src1, length1, mPrevWord);
|
||||||
|
if (twoWordsLen >= MAX_WORD_LENGTH) {
|
||||||
|
twoWordsLen = MAX_WORD_LENGTH - 1;
|
||||||
|
}
|
||||||
mPrevWord[twoWordsLen] = KEYCODE_SPACE;
|
mPrevWord[twoWordsLen] = KEYCODE_SPACE;
|
||||||
mPrevWordStart = length0;
|
mPrevWordStart = length0;
|
||||||
mPrevWordLength = static_cast<int16_t>(twoWordsLen + 1);
|
mPrevWordLength = static_cast<int16_t>(twoWordsLen + 1);
|
||||||
|
|
Loading…
Reference in New Issue