Add check that dexlayout can open output file.

Test: mm test-art-host
Change-Id: I49b37b3e3696c8c002e22533c2e86e47a0e13e51
diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc
index 0536f322..0e0d66b 100644
--- a/dexlayout/dexlayout.cc
+++ b/dexlayout/dexlayout.cc
@@ -1816,6 +1816,10 @@
       output_location += "/" + dex_file_location + ".new";
     }
     new_file.reset(OS::CreateEmptyFile(output_location.c_str()));
+    if (new_file == nullptr) {
+      LOG(ERROR) << "Could not create dex writer output file: " << output_location;
+      return;
+    }
     ftruncate(new_file->Fd(), header_->FileSize());
     mem_map_.reset(MemMap::MapFile(header_->FileSize(), PROT_READ | PROT_WRITE, MAP_SHARED,
         new_file->Fd(), 0, /*low_4gb*/ false, output_location.c_str(), &error_msg));
@@ -1825,7 +1829,7 @@
   }
   if (mem_map_ == nullptr) {
     LOG(ERROR) << "Could not create mem map for dex writer output: " << error_msg;
-    if (new_file.get() != nullptr) {
+    if (new_file != nullptr) {
       new_file->Erase();
     }
     return;