Merge "Throw exception when the header cannot be read."
diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java
index 315bd8e..71e120c 100644
--- a/java/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java
+++ b/java/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java
@@ -173,6 +173,9 @@
     @Override
     public DictionaryHeader readHeader() throws IOException, UnsupportedFormatException {
         final DictionaryHeader header = mBinaryDictionary.getHeader();
+        if (header == null) {
+            throw new IOException("Cannot read the dictionary header.");
+        }
         if (header.mFormatOptions.mVersion != FormatSpec.VERSION2) {
             throw new UnsupportedFormatException("File header has a wrong version : "
                     + header.mFormatOptions.mVersion);