summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2015-01-08 02:44:30 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-01-08 02:44:31 +0000
commit4270e74152d8a7cd979ab5a92fe2a8f84adb8a42 (patch)
treebc1d6b8c000081ce24f75d3218f75c16f08e7854
parent5a9f8a79e8f133b00f8a31bade95336b634c2326 (diff)
parenta2cfee3854193d541530f511ea328b0c1a3136c6 (diff)
downloadart-4270e74152d8a7cd979ab5a92fe2a8f84adb8a42.zip
art-4270e74152d8a7cd979ab5a92fe2a8f84adb8a42.tar.gz
art-4270e74152d8a7cd979ab5a92fe2a8f84adb8a42.tar.bz2
Merge "Fix valgrind imgdiag test failure / memory leak in runtime"
-rw-r--r--runtime/runtime.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index e91f7c0..a2c9f50 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -858,6 +858,7 @@ bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized)
CHECK_GE(GetHeap()->GetContinuousSpaces().size(), 1U);
class_linker_ = new ClassLinker(intern_table_);
+ bool options_class_path_used = false;
if (GetHeap()->HasImageSpace()) {
class_linker_->InitFromImage();
if (kIsDebugBuild) {
@@ -881,7 +882,16 @@ bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized)
CHECK(options->boot_class_path_ != nullptr);
CHECK_NE(options->boot_class_path_->size(), 0U);
class_linker_->InitWithoutImage(*options->boot_class_path_);
+ options_class_path_used = true;
}
+
+ if (!options_class_path_used) {
+ // If the class linker does not take ownership of the boot class path, wipe it to prevent leaks.
+ auto boot_class_path_vector_ptr =
+ const_cast<std::vector<const DexFile*>*>(options->boot_class_path_);
+ STLDeleteElements(boot_class_path_vector_ptr);
+ }
+
CHECK(class_linker_ != nullptr);
// Initialize the special sentinel_ value early.