summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christian Egtvedt <hegtvedt@cisco.com>2020-04-02 17:28:19 +0200
committerDave Watson <dade.watson@gmail.com>2020-04-29 08:35:19 -0700
commita8b94341faf8b04d9041bbaecb54481b70295a6c (patch)
tree6754c38b7db05ee4a3e1f394a959ddb23fc9519a
parentd866775860bcc8d26406c4b73bd1e285c7ea0c23 (diff)
downloadlibunwind-a8b94341faf8b04d9041bbaecb54481b70295a6c.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)