summaryrefslogtreecommitdiffstats
path: root/dex2oat
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2014-12-03 14:28:02 -0800
committerAndreas Gampe <agampe@google.com>2014-12-03 15:24:28 -0800
commita650e700ddcfef0ad86284b0f0818543a196014a (patch)
treef371644862308801796176cb9bda460489691382 /dex2oat
parent27478e627e08ab42c43d5d934da9ea336ccaf628 (diff)
downloadart-a650e700ddcfef0ad86284b0f0818543a196014a.tar.gz
art-a650e700ddcfef0ad86284b0f0818543a196014a.tar.bz2
art-a650e700ddcfef0ad86284b0f0818543a196014a.zip
ART: Fix unclosed files in dex2oat
Under some error conditions files are not closed, and the close guard will complain. Bug: 18603475 (cherry picked from commit d97465c3742cc3c82843665f2678b881de29854b) Change-Id: I7155e3f4f6231844edd375b9302ecf1ba8079950
Diffstat (limited to 'dex2oat')
-rw-r--r--dex2oat/dex2oat.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index a1ac2f0761..25d6db16b4 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -987,6 +987,12 @@ class Dex2Oat FINAL {
return true;
}
+ void EraseOatFile() {
+ DCHECK(oat_file_.get() != nullptr);
+ oat_file_->Erase();
+ oat_file_.reset();
+ }
+
// Set up the environment for compilation. Includes starting the runtime and loading/opening the
// boot class path.
bool Setup() {
@@ -1301,7 +1307,6 @@ class Dex2Oat FINAL {
if (!driver_->WriteElf(android_root_, is_host_, dex_files_, oat_writer.get(),
oat_file_.get())) {
LOG(ERROR) << "Failed to write ELF file " << oat_file_->GetPath();
- oat_file_->Erase();
return false;
}
}
@@ -1712,6 +1717,7 @@ static int CompileImage(Dex2Oat& dex2oat) {
// Create the boot.oat.
if (!dex2oat.CreateOatFile()) {
+ dex2oat.EraseOatFile();
return EXIT_FAILURE;
}
@@ -1756,6 +1762,7 @@ static int CompileApp(Dex2Oat& dex2oat) {
// Create the app oat.
if (!dex2oat.CreateOatFile()) {
+ dex2oat.EraseOatFile();
return EXIT_FAILURE;
}
@@ -1813,6 +1820,7 @@ static int dex2oat(int argc, char** argv) {
LOG(INFO) << CommandLine();
if (!dex2oat.Setup()) {
+ dex2oat.EraseOatFile();
return EXIT_FAILURE;
}