summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christian Egtvedt <hegtvedt@cisco.com>2020-04-02 17:28:19 +0200
committerGitHub <noreply@github.com>2020-04-02 08:28:19 -0700
commit11fd461095ea98f4b3e3a361f5a8a558519363fa (patch)
tree05c108137c37730a1bf3a2e7f8eb2c45f70114f8
parent0c1d83a661d1daed7bb7e8389e9bdef7a4bb614f (diff)
downloadlibunwind-11fd461095ea98f4b3e3a361f5a8a558519363fa.tar.gz
coredump: Unmap elf image before mapping another (#169)
Make sure to unmap the currently mapped elf image before mapping another image in CD_get_proc_name. If not, the reference to that image is lost and the memory is leaked. Signed-off-by: Sturle Mastberg <smastber@cisco.com> Signed-off-by: Hans-Christian Noren Egtvedt <hegtvedt@cisco.com>
-rw-r--r--src/coredump/_UCD_get_proc_name.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/coredump/_UCD_get_proc_name.c b/src/coredump/_UCD_get_proc_name.c
index 00096c48..3a4c9b82 100644
--- a/src/coredump/_UCD_get_proc_name.c
+++ b/src/coredump/_UCD_get_proc_name.c
@@ -36,6 +36,10 @@ elf_w (CD_get_proc_name) (struct UCD_info *ui, unw_addr_space_t as, unw_word_t i
unsigned long segbase, mapoff;
int ret;
+ /* We're about to map an elf image. If there is an elf image currently mapped,
+ then make sure to unmap it. */
+ invalidate_edi(&ui->edi);
+
/* Used to be tdep_get_elf_image() in ptrace unwinding code */
coredump_phdr_t *cphdr = _UCD_get_elf_image(ui, ip);
if (!cphdr)