Merge "Boundary check for ProximityInfoState::getProximityTypeG()."

main
Keisuke Kuroyanagi 2014-01-10 11:24:22 +00:00 committed by Android (Google) Code Review
commit 4db09448e9
1 changed files with 8 additions and 0 deletions

View File

@ -255,6 +255,14 @@ ProximityType ProximityInfoState::getProximityTypeG(const int index, const int c
if (!isUsed()) { if (!isUsed()) {
return UNRELATED_CHAR; return UNRELATED_CHAR;
} }
const int sampledSearchKeyVectorsSize = static_cast<int>(mSampledSearchKeyVectors.size());
if (index < 0 || index >= sampledSearchKeyVectorsSize) {
AKLOGE("getProximityTypeG() is called with an invalid index(%d). "
"mSampledSearchKeyVectors.size() = %d, codePoint = %x.", index,
sampledSearchKeyVectorsSize, codePoint);
ASSERT(false);
return UNRELATED_CHAR;
}
const int lowerCodePoint = CharUtils::toLowerCase(codePoint); const int lowerCodePoint = CharUtils::toLowerCase(codePoint);
const int baseLowerCodePoint = CharUtils::toBaseCodePoint(lowerCodePoint); const int baseLowerCodePoint = CharUtils::toBaseCodePoint(lowerCodePoint);
for (int i = 0; i < static_cast<int>(mSampledSearchKeyVectors[index].size()); ++i) { for (int i = 0; i < static_cast<int>(mSampledSearchKeyVectors[index].size()); ++i) {