Merge "Move Constants.java to the latin.common package"
diff --git a/java/src/com/android/inputmethod/event/DeadKeyCombiner.java b/java/src/com/android/inputmethod/event/DeadKeyCombiner.java
index cb1100d..a3e4ad8 100644
--- a/java/src/com/android/inputmethod/event/DeadKeyCombiner.java
+++ b/java/src/com/android/inputmethod/event/DeadKeyCombiner.java
@@ -218,7 +218,10 @@
     @Nonnull
     private static Event createEventChainFromSequence(final @Nonnull CharSequence text,
             @Nonnull final Event originalEvent) {
-        Event lastEvent = originalEvent;
+        if (text.length() <= 0) {
+            return originalEvent;
+        }
+        Event lastEvent = null;
         int codePoint = 0;
         for (int i = text.length(); i > 0; i -= Character.charCount(codePoint)) {
             codePoint = Character.codePointBefore(text, i);
diff --git a/native/jni/HostUnitTests.mk b/native/jni/HostUnitTests.mk
index 40ec255..e30d50a 100644
--- a/native/jni/HostUnitTests.mk
+++ b/native/jni/HostUnitTests.mk
@@ -29,8 +29,10 @@
 #################### Host library for unit test
 # TODO: Remove -std=c++11 once it is set by default on host build.
 LATIN_IME_SRC_DIR := src
+LOCAL_ADDRESS_SANITIZER := true
 LOCAL_CFLAGS += -std=c++11 -Wno-unused-parameter -Wno-unused-function
 LOCAL_CLANG := true
+LOCAL_CXX_STL := libc++
 LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
 LOCAL_MODULE := liblatinime_host_static_for_unittests
 LOCAL_MODULE_TAGS := optional
@@ -40,9 +42,11 @@
 #################### Host native tests
 include $(CLEAR_VARS)
 LATIN_IME_TEST_SRC_DIR := tests
+LOCAL_ADDRESS_SANITIZER := true
 # TODO: Remove -std=c++11 once it is set by default on host build.
 LOCAL_CFLAGS += -std=c++11 -Wno-unused-parameter -Wno-unused-function
 LOCAL_CLANG := true
+LOCAL_CXX_STL := libc++
 LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
 LOCAL_MODULE := liblatinime_host_unittests
 LOCAL_MODULE_TAGS := tests
diff --git a/native/jni/src/suggest/core/dicnode/dic_node_utils.cpp b/native/jni/src/suggest/core/dicnode/dic_node_utils.cpp
index 7d2898b..ea43892 100644
--- a/native/jni/src/suggest/core/dicnode/dic_node_utils.cpp
+++ b/native/jni/src/suggest/core/dicnode/dic_node_utils.cpp
@@ -74,8 +74,9 @@
     }
     const WordAttributes wordAttributes = dictionaryStructurePolicy->getWordAttributesInContext(
             dicNode->getPrevWordIds(), dicNode->getWordId(), multiBigramMap);
-    if (dicNode->hasMultipleWords()
-            && (wordAttributes.isBlacklisted() || wordAttributes.isNotAWord())) {
+    if (wordAttributes.getProbability() == NOT_A_PROBABILITY
+            || (dicNode->hasMultipleWords()
+                    && (wordAttributes.isBlacklisted() || wordAttributes.isNotAWord()))) {
         return static_cast<float>(MAX_VALUE_FOR_WEIGHTING);
     }
     // TODO: This equation to calculate the improbability looks unreasonable.  Investigate this.