diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index cdaffa655a8f1c36c6d48c55b5d42351fcc91989..726c44cc15e05b557a46ebdc49a9160ed31555b0 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -162,7 +162,7 @@ public class BinaryDictionary extends Dictionary {
             if (composerSize > 0 && mOutputScores[j] < 1) break;
             final int start = j * MAX_WORD_LENGTH;
             int len = 0;
-            while (len <  MAX_WORD_LENGTH && mOutputChars[start + len] != 0) {
+            while (len < MAX_WORD_LENGTH && mOutputChars[start + len] != 0) {
                 ++len;
             }
             if (len > 0) {
diff --git a/native/jni/src/debug.h b/native/jni/src/debug.h
index 4e2164014c4182fc65c8ca072d8f8602aff0b5cf..8f6b69d772e840a33dbe4f0704df27558a20eab4 100644
--- a/native/jni/src/debug.h
+++ b/native/jni/src/debug.h
@@ -22,7 +22,7 @@
 static inline unsigned char *convertToUnibyteString(unsigned short *input, unsigned char *output,
         const unsigned int length) {
     unsigned int i = 0;
-    for (; i <= length && input[i] != 0; ++i)
+    for (; i < length && input[i] != 0; ++i)
         output[i] = input[i] & 0xFF;
     output[i] = 0;
     return output;
@@ -31,7 +31,7 @@ static inline unsigned char *convertToUnibyteString(unsigned short *input, unsig
 static inline unsigned char *convertToUnibyteStringAndReplaceLastChar(unsigned short *input,
         unsigned char *output, const unsigned int length, unsigned char c) {
     unsigned int i = 0;
-    for (; i <= length && input[i] != 0; ++i)
+    for (; i < length && input[i] != 0; ++i)
         output[i] = input[i] & 0xFF;
     if (i > 0) output[i-1] = c;
     output[i] = 0;