Fix CTS crash from DexFile refactoring

Avoid path to nullptr access introduced by the previous refactoring.

Bug: 22322814
Change-Id: Id8874b26c072a11b0494e8126f8b0602a7c5b9e8
Test: m test-art-host, cts-tradefed run cts --skip-preconditions --skip-device-info --module vm-tests-tf
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index 409fbba..0af086c 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -323,7 +323,7 @@
   ScopedTrace trace("Dex file open from Zip Archive " + std::string(location));
   CHECK(!location.empty());
   std::unique_ptr<ZipEntry> zip_entry(zip_archive.Find(entry_name, error_msg));
-  if (zip_entry.get() == nullptr) {
+  if (zip_entry == nullptr) {
     *error_code = ZipOpenErrorCode::kEntryNotFound;
     return nullptr;
   }
@@ -333,7 +333,7 @@
     return nullptr;
   }
   std::unique_ptr<MemMap> map(zip_entry->ExtractToMemMap(location.c_str(), entry_name, error_msg));
-  if (map.get() == nullptr) {
+  if (map == nullptr) {
     *error_msg = StringPrintf("Failed to extract '%s' from '%s': %s", entry_name, location.c_str(),
                               error_msg->c_str());
     *error_code = ZipOpenErrorCode::kExtractToMemoryError;
@@ -349,9 +349,15 @@
                                                  verify_checksum,
                                                  error_msg,
                                                  &verify_result);
-  if (dex_file != nullptr) {
-    dex_file->mem_map_.reset(map.release());
+  if (dex_file == nullptr) {
+    if (verify_result == VerifyResult::kVerifyNotAttempted) {
+      *error_code = ZipOpenErrorCode::kDexFileError;
+    } else {
+      *error_code = ZipOpenErrorCode::kVerifyError;
+    }
+    return nullptr;
   }
+  dex_file->mem_map_.reset(map.release());
   if (!dex_file->DisableWrite()) {
     *error_msg = StringPrintf("Failed to make dex file '%s' read only", location.c_str());
     *error_code = ZipOpenErrorCode::kMakeReadOnlyError;
@@ -440,6 +446,9 @@
                                              bool verify_checksum,
                                              std::string* error_msg,
                                              VerifyResult* verify_result) {
+  if (verify_result != nullptr) {
+    *verify_result = VerifyResult::kVerifyNotAttempted;
+  }
   std::unique_ptr<DexFile> dex_file(new DexFile(base,
                                                 size,
                                                 location,