Do not dump memory usage if driver was never created

Bug: https://code.google.com/p/android/issues/detail?id=158593
Change-Id: I8084f9ac823910aa11f854f3e764240741fbf0d5
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 8572f4d..128f623 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1647,9 +1647,10 @@
   void LogCompletionTime() {
     // Note: when creation of a runtime fails, e.g., when trying to compile an app but when there
     //       is no image, there won't be a Runtime::Current().
+    // Note: driver creation can fail when loading an invalid dex file.
     LOG(INFO) << "dex2oat took " << PrettyDuration(NanoTime() - start_ns_)
               << " (threads: " << thread_count_ << ") "
-              << ((Runtime::Current() != nullptr) ?
+              << ((Runtime::Current() != nullptr && driver_.get() != nullptr) ?
                   driver_->GetMemoryUsageString(kIsDebugBuild || VLOG_IS_ON(compiler)) :
                   "");
   }