Fix a few more scoped_ptr/scoped_array confusions, and stop tring to optimistically load non-existent .dex files.

Change-Id: I0c12a731bdf1da49f2f51665181e5b4d2b423ba2
diff --git a/src/dex_file.cc b/src/dex_file.cc
index 3cddd7f..0645a65 100644
--- a/src/dex_file.cc
+++ b/src/dex_file.cc
@@ -151,13 +151,15 @@
                                 adjacent_dex_filename.end(),
                                 ".dex");
   // Example adjacent_dex_filename = dir/foo.dex
-  // TODO: stat first, so we don't report a bogus error.
-  DexFile* adjacent_dex_file = DexFile::OpenFile(adjacent_dex_filename);
-  if (adjacent_dex_file != NULL) {
+  struct stat sb;
+  if (stat(adjacent_dex_filename.c_str(), &sb) == 0) {
+    DexFile* adjacent_dex_file = DexFile::OpenFile(adjacent_dex_filename);
+    if (adjacent_dex_file != NULL) {
       // We don't verify anything in this case, because we aren't in
       // the cache and typically the file is in the readonly /system
       // area, so if something is wrong, there is nothing we can do.
       return adjacent_dex_file;
+    }
   }
 
   char resolved[PATH_MAX];
@@ -256,7 +258,7 @@
       return NULL;
     }
     const size_t kBufSize = 32768;
-    scoped_ptr<uint8_t> buf(new uint8_t[kBufSize]);
+    scoped_array<uint8_t> buf(new uint8_t[kBufSize]);
     if (buf == NULL) {
       return NULL;
     }
diff --git a/src/dex_file_test.cc b/src/dex_file_test.cc
index 33c43c9..616e1c4 100644
--- a/src/dex_file_test.cc
+++ b/src/dex_file_test.cc
@@ -79,8 +79,8 @@
     const char* name = raw->dexStringById(method_id.name_idx_);
     ASSERT_STREQ("<init>", name);
     int32_t length;
-    scoped_ptr<const char> descriptor(raw->CreateMethodDescriptor(proto_idx,
-                                                                  &length));
+    scoped_array<const char> descriptor(raw->CreateMethodDescriptor(proto_idx,
+        &length));
     ASSERT_STREQ("()V", descriptor.get());
   }
 
@@ -98,8 +98,8 @@
 
     uint32_t proto_idx = method_id.proto_idx_;
     int32_t length;
-    scoped_ptr<const char> descriptor(raw->CreateMethodDescriptor(proto_idx,
-                                                                  &length));
+    scoped_array<const char> descriptor(raw->CreateMethodDescriptor(proto_idx,
+        &length));
     ASSERT_STREQ("(IDJLjava/lang/Object;)Ljava/lang/Float;", descriptor.get());
   }
 
@@ -113,8 +113,8 @@
 
     uint32_t proto_idx = method_id.proto_idx_;
     int32_t length;
-    scoped_ptr<const char> descriptor(raw->CreateMethodDescriptor(proto_idx,
-                                                                  &length));
+    scoped_array<const char> descriptor(raw->CreateMethodDescriptor(proto_idx,
+        &length));
     ASSERT_STREQ("(ZSC)LCreateMethodDescriptor;", descriptor.get());
   }
 
diff --git a/src/zip_archive.cc b/src/zip_archive.cc
index e44b855..2c63150 100644
--- a/src/zip_archive.cc
+++ b/src/zip_archive.cc
@@ -175,8 +175,8 @@
 
 static bool InflateToFd(int out, int in, size_t uncompressed_length, size_t compressed_length) {
   const size_t kBufSize = 32768;
-  scoped_ptr<uint8_t> read_buf(new uint8_t[kBufSize]);
-  scoped_ptr<uint8_t> write_buf(new uint8_t[kBufSize]);
+  scoped_array<uint8_t> read_buf(new uint8_t[kBufSize]);
+  scoped_array<uint8_t> write_buf(new uint8_t[kBufSize]);
   if (read_buf == NULL || write_buf == NULL) {
     return false;
   }