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 e1b35340beff5ed80130f74a10f89ebce03f447a..bc4ca8e9ed4722e53c1ce15baa4e3f35b18614f5 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;