From: Dmitriy Ivanov Date: Fri, 6 Nov 2015 18:44:37 +0000 (-0800) Subject: linker: cleanup solist after unsuccessful read X-Git-Tag: android-x86-7.1-r1~362^2~15^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=fd7a91e69263a991f65fa458ff33de0670b4fd81;p=android-x86%2Fbionic.git linker: cleanup solist after unsuccessful read Bug: http://b/25560017 Change-Id: I03c5a1d7aed34c480d341aacfb3b1afdfa037b99 --- diff --git a/linker/linker.cpp b/linker/linker.cpp index 9f0b559b9..31ed1ec19 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -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; } diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp index baf7eb595..c7d4d462f 100644 --- a/tests/dlext_test.cpp +++ b/tests/dlext_test.cpp @@ -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); }