am 7d2a0db7: Merge "Add boundary check for PtNode reading position."
* commit '7d2a0db7d76e8865d9f5f5110caab47f3287e81b': Add boundary check for PtNode reading position.main
commit
dfc51ec98b
|
@ -25,6 +25,13 @@ namespace latinime {
|
||||||
|
|
||||||
void DynamicPatriciaTrieNodeReader::fetchNodeInfoFromBufferAndProcessMovedNode(const int nodePos,
|
void DynamicPatriciaTrieNodeReader::fetchNodeInfoFromBufferAndProcessMovedNode(const int nodePos,
|
||||||
const int maxCodePointCount, int *const outCodePoints) {
|
const int maxCodePointCount, int *const outCodePoints) {
|
||||||
|
if (nodePos < 0 || nodePos >= mBuffer->getTailPosition()) {
|
||||||
|
AKLOGE("Fetching PtNode info form invalid dictionary position: %d, dictionary size: %d",
|
||||||
|
nodePos, mBuffer->getTailPosition());
|
||||||
|
ASSERT(false);
|
||||||
|
invalidatePtNodeInfo();
|
||||||
|
return;
|
||||||
|
}
|
||||||
const bool usesAdditionalBuffer = mBuffer->isInAdditionalBuffer(nodePos);
|
const bool usesAdditionalBuffer = mBuffer->isInAdditionalBuffer(nodePos);
|
||||||
const uint8_t *const dictBuf = mBuffer->getBuffer(usesAdditionalBuffer);
|
const uint8_t *const dictBuf = mBuffer->getBuffer(usesAdditionalBuffer);
|
||||||
int pos = nodePos;
|
int pos = nodePos;
|
||||||
|
@ -94,4 +101,19 @@ void DynamicPatriciaTrieNodeReader::fetchNodeInfoFromBufferAndProcessMovedNode(c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DynamicPatriciaTrieNodeReader::invalidatePtNodeInfo() {
|
||||||
|
mHeadPos = NOT_A_VALID_WORD_POS;
|
||||||
|
mFlags = 0;
|
||||||
|
mParentPos = NOT_A_DICT_POS;
|
||||||
|
mCodePointCount = 0;
|
||||||
|
mProbabilityFieldPos = NOT_A_DICT_POS;
|
||||||
|
mProbability = NOT_A_PROBABILITY;
|
||||||
|
mChildrenPosFieldPos = NOT_A_DICT_POS;
|
||||||
|
mChildrenPos = NOT_A_DICT_POS;
|
||||||
|
mBigramLinkedNodePos = NOT_A_DICT_POS;
|
||||||
|
mShortcutPos = NOT_A_DICT_POS;
|
||||||
|
mBigramPos = NOT_A_DICT_POS;
|
||||||
|
mSiblingPos = NOT_A_VALID_WORD_POS;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,6 +156,8 @@ class DynamicPatriciaTrieNodeReader {
|
||||||
|
|
||||||
void fetchNodeInfoFromBufferAndProcessMovedNode(const int nodePos, const int maxCodePointCount,
|
void fetchNodeInfoFromBufferAndProcessMovedNode(const int nodePos, const int maxCodePointCount,
|
||||||
int *const outCodePoints);
|
int *const outCodePoints);
|
||||||
|
|
||||||
|
void invalidatePtNodeInfo();
|
||||||
};
|
};
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
#endif /* LATINIME_DYNAMIC_PATRICIA_TRIE_NODE_READER_H */
|
#endif /* LATINIME_DYNAMIC_PATRICIA_TRIE_NODE_READER_H */
|
||||||
|
|
Loading…
Reference in New Issue