diff --git a/native/jni/src/suggest/core/layout/proximity_info_state.cpp b/native/jni/src/suggest/core/layout/proximity_info_state.cpp index bb4b41714..de99e2f0c 100644 --- a/native/jni/src/suggest/core/layout/proximity_info_state.cpp +++ b/native/jni/src/suggest/core/layout/proximity_info_state.cpp @@ -255,6 +255,14 @@ ProximityType ProximityInfoState::getProximityTypeG(const int index, const int c if (!isUsed()) { return UNRELATED_CHAR; } + const int sampledSearchKeyVectorsSize = static_cast(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 baseLowerCodePoint = CharUtils::toBaseCodePoint(lowerCodePoint); for (int i = 0; i < static_cast(mSampledSearchKeyVectors[index].size()); ++i) {