am 9cfa8417: Merge "Add boundary check for ver2 dict reading."
* commit '9cfa8417dacb1d3efc687c8b9c5a7f141f5f7746': Add boundary check for ver2 dict reading.main
commit
acf61fbdf5
|
@ -87,9 +87,24 @@ int PatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCount(
|
|||
int lastCandidatePtNodePos = 0;
|
||||
// Let's loop through PtNodes in this PtNode array searching for either the terminal
|
||||
// or one of its ascendants.
|
||||
if (pos < 0 || pos >= mDictBufferSize) {
|
||||
AKLOGE("PtNode array position is invalid. pos: %d, dict size: %d",
|
||||
pos, mDictBufferSize);
|
||||
mIsCorrupted = true;
|
||||
ASSERT(false);
|
||||
*outUnigramProbability = NOT_A_PROBABILITY;
|
||||
return 0;
|
||||
}
|
||||
for (int ptNodeCount = PatriciaTrieReadingUtils::getPtNodeArraySizeAndAdvancePosition(
|
||||
mDictRoot, &pos); ptNodeCount > 0; --ptNodeCount) {
|
||||
const int startPos = pos;
|
||||
if (pos < 0 || pos >= mDictBufferSize) {
|
||||
AKLOGE("PtNode position is invalid. pos: %d, dict size: %d", pos, mDictBufferSize);
|
||||
mIsCorrupted = true;
|
||||
ASSERT(false);
|
||||
*outUnigramProbability = NOT_A_PROBABILITY;
|
||||
return 0;
|
||||
}
|
||||
const PatriciaTrieReadingUtils::NodeFlags flags =
|
||||
PatriciaTrieReadingUtils::getFlagsAndAdvancePosition(mDictRoot, &pos);
|
||||
const int character = PatriciaTrieReadingUtils::getCodePointAndAdvancePosition(
|
||||
|
|
Loading…
Reference in New Issue