Add nullptr and size check for opening a mem mapped dex file.

The bug has an apk with 0 size classes.dex. When dex2oat tries to open
the file for layout, it crashes. This adds checks to ensure that the mem
map isn't null and has a sane size before opening it as a dex file.

Bug: 35892406
Test: mm test-art-host
Change-Id: I5f6b5a1e7bbccf4fe3483b68023d51436eb71805
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index b6a2e09..35e9d5d 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -179,6 +179,14 @@
                                              std::string* error_msg) {
   ScopedTrace trace(std::string("Open dex file from mapped-memory ") + location);
   CHECK(map.get() != nullptr);
+
+  if (map->Size() < sizeof(DexFile::Header)) {
+    *error_msg = StringPrintf(
+        "DexFile: failed to open dex file '%s' that is too short to have a header",
+        location.c_str());
+    return nullptr;
+  }
+
   std::unique_ptr<DexFile> dex_file = OpenCommon(map->Begin(),
                                                  map->Size(),
                                                  location,