summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2014-12-11 19:16:39 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2014-12-11 19:16:39 +0000
commitf41ac3d237d24b9a4b6fb33e7edb67320cdb1900 (patch)
tree9d5ced102fd0848f0b5283b6a613724dfd1abc6a /runtime/class_linker.cc
parent86ff0892aae3b13a105ce2fd58c39591f315c049 (diff)
parenta696c0a27f9b9cdf68ac17bdb4e29ac1f798ac32 (diff)
Merge "ART: More ELF and oat file safety measures"
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 1f4cf8fcfc..a225f60291 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -21,6 +21,7 @@
#include <memory>
#include <queue>
#include <string>
+#include <unistd.h>
#include <utility>
#include <vector>
@@ -704,7 +705,14 @@ bool ClassLinker::GenerateOatFile(const char* dex_filename,
argv.push_back(compiler_options[i].c_str());
}
- return Exec(argv, error_msg);
+ if (!Exec(argv, error_msg)) {
+ // Manually delete the file. Ensures there is no garbage left over if the process unexpectedly
+ // died. Ignore unlink failure, propagate the original error.
+ TEMP_FAILURE_RETRY(unlink(oat_cache_filename));
+ return false;
+ }
+
+ return true;
}
const OatFile* ClassLinker::RegisterOatFile(const OatFile* oat_file) {