From 33e38096ad68164a4033eb5a77df75a532f3a7ec Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Mon, 24 Feb 2014 20:40:16 +0900 Subject: [PATCH] Fix: -1 can be used as a code point of most probable string. Bug: 11797518 Change-Id: Id2e8bce92d000f39d506af7cb844447696bcc019 --- .../core/layout/proximity_info_state_utils.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/native/jni/src/suggest/core/layout/proximity_info_state_utils.cpp b/native/jni/src/suggest/core/layout/proximity_info_state_utils.cpp index e1b35340b..bc4ca8e9e 100644 --- a/native/jni/src/suggest/core/layout/proximity_info_state_utils.cpp +++ b/native/jni/src/suggest/core/layout/proximity_info_state_utils.cpp @@ -992,7 +992,16 @@ namespace latinime { } } if (character != NOT_AN_INDEX) { - codePointBuf[index] = proximityInfo->getCodePointOf(character); + const int codePoint = proximityInfo->getCodePointOf(character); + if (codePoint == NOT_A_CODE_POINT) { + AKLOGE("Key index(%d) is not found. Cannot construct most probable string", + character); + ASSERT(false); + // Make the length zero, which means most probable string won't be used. + index = 0; + break; + } + codePointBuf[index] = codePoint; index++; } sumLogProbability += minLogProbability;