OSDN Git Service

ART: Fix two allocation/deallocation mismatches.
authorVladimir Marko <vmarko@google.com>
Thu, 17 Sep 2015 19:22:02 +0000 (20:22 +0100)
committerVladimir Marko <vmarko@google.com>
Thu, 17 Sep 2015 19:22:02 +0000 (20:22 +0100)
Change-Id: I5088126cbd5b5e4b461a449eecd5b3574883f413

runtime/dex_file_verifier_test.cc
runtime/oat_file.cc

index 1b529c9..272249c 100644 (file)
@@ -117,7 +117,7 @@ static void FixUpChecksum(uint8_t* dex_file) {
 struct DexFileDeleter {
   void operator()(DexFile* in) {
     if (in != nullptr) {
-      delete in->Begin();
+      delete[] in->Begin();
       delete in;
     }
   }
index a23d94d..a4a159e 100644 (file)
@@ -224,18 +224,20 @@ bool OatFile::Dlopen(const std::string& elf_filename, uint8_t* requested_base,
   UNUSED(error_msg);
   return false;
 #else
-  std::unique_ptr<char> absolute_path(realpath(elf_filename.c_str(), nullptr));
-  if (absolute_path == nullptr) {
-    *error_msg = StringPrintf("Failed to find absolute path for '%s'", elf_filename.c_str());
-    return false;
-  }
+  {
+    UniqueCPtr<char> absolute_path(realpath(elf_filename.c_str(), nullptr));
+    if (absolute_path == nullptr) {
+      *error_msg = StringPrintf("Failed to find absolute path for '%s'", elf_filename.c_str());
+      return false;
+    }
 #ifdef __ANDROID__
-  android_dlextinfo extinfo;
-  extinfo.flags = ANDROID_DLEXT_FORCE_LOAD | ANDROID_DLEXT_FORCE_FIXED_VADDR;
-  dlopen_handle_ = android_dlopen_ext(absolute_path.get(), RTLD_NOW, &extinfo);
+    android_dlextinfo extinfo;
+    extinfo.flags = ANDROID_DLEXT_FORCE_LOAD | ANDROID_DLEXT_FORCE_FIXED_VADDR;
+    dlopen_handle_ = android_dlopen_ext(absolute_path.get(), RTLD_NOW, &extinfo);
 #else
-  dlopen_handle_ = dlopen(absolute_path.get(), RTLD_NOW);
+    dlopen_handle_ = dlopen(absolute_path.get(), RTLD_NOW);
 #endif
+  }
   if (dlopen_handle_ == nullptr) {
     *error_msg = StringPrintf("Failed to dlopen '%s': %s", elf_filename.c_str(), dlerror());
     return false;