Merge "linker: Fix memory leak for reserved memory" am: f81ceb939e
am: a64695952d
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2370012 Change-Id: I61d37cd4dfb66ba75506b05b974bef1267538236 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
c7dc6c3fe1
1 changed files with 9 additions and 1 deletions
|
@ -175,7 +175,8 @@ bool ElfReader::Load(address_space_params* address_space) {
|
|||
if (did_load_) {
|
||||
return true;
|
||||
}
|
||||
if (ReserveAddressSpace(address_space) && LoadSegments() && FindPhdr() &&
|
||||
bool reserveSuccess = ReserveAddressSpace(address_space);
|
||||
if (reserveSuccess && LoadSegments() && FindPhdr() &&
|
||||
FindGnuPropertySection()) {
|
||||
did_load_ = true;
|
||||
#if defined(__aarch64__)
|
||||
|
@ -186,6 +187,13 @@ bool ElfReader::Load(address_space_params* address_space) {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
if (reserveSuccess && !did_load_) {
|
||||
if (load_start_ != nullptr && load_size_ != 0) {
|
||||
if (!mapped_by_caller_) {
|
||||
munmap(load_start_, load_size_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return did_load_;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue