Fix potential NPE

Change-Id: I3679d24b6c89e081d24d59c91b136c139dcb3d5c
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 5d8fd34..64f7e60 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -546,8 +546,9 @@
         // know now whether this is a password text field, because we need to know now whether we
         // want to enable the voice button.
         final VoiceProxy voiceIme = mVoiceProxy;
-        voiceIme.resetVoiceStates(InputTypeCompatUtils.isPasswordInputType(attribute.inputType)
-                || InputTypeCompatUtils.isVisiblePasswordInputType(attribute.inputType));
+        final int inputType = (attribute != null) ? attribute.inputType : 0;
+        voiceIme.resetVoiceStates(InputTypeCompatUtils.isPasswordInputType(inputType)
+                || InputTypeCompatUtils.isVisiblePasswordInputType(inputType));
 
         initializeInputAttributes(attribute);