Merge "linker: cleanup solist after unsuccessful read"

am: 3482613685

* commit '3482613685342da365a7569220f8e6c27a1fe7e5':
  linker: cleanup solist after unsuccessful read
This commit is contained in:
Dimitry Ivanov 2015-11-06 19:02:08 +00:00 committed by android-build-merger
commit bc0b61e407
2 changed files with 7 additions and 0 deletions

View File

@ -1523,6 +1523,8 @@ static bool load_library(LoadTask* task,
// Read the ELF header and some of the segments.
if (!task->read(realpath.c_str(), file_stat.st_size)) {
soinfo_free(si);
task->set_soinfo(nullptr);
return false;
}

View File

@ -169,6 +169,11 @@ TEST_F(DlExtTest, ExtInfoUseFdWithInvalidOffset) {
ASSERT_TRUE(handle_ == nullptr);
ASSERT_EQ("dlopen failed: \"" + lib_realpath + "\" has bad ELF magic", dlerror());
// Check if dlsym works after unsuccessful dlopen().
// Supply non-exiting one to make linker visit every soinfo.
void* sym = dlsym(RTLD_DEFAULT, "this_symbol_does_not_exist___");
ASSERT_TRUE(sym == nullptr);
close(extinfo.library_fd);
}