]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: Don't install an Elf handle in a Dwfl_Module twice
authorMark Wielaard <mark@klomp.org>
Wed, 8 Dec 2021 22:44:34 +0000 (23:44 +0100)
committerMark Wielaard <mark@klomp.org>
Thu, 9 Dec 2021 18:34:19 +0000 (19:34 +0100)
dwfl_segment_report_module can be called with the same module
name, start and end address twice (probably because of a corrupt
core file). In that case don't override the main.elf handle if
it already exists.

https://sourceware.org/bugzilla/show_bug.cgi?id=28655

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdwfl/ChangeLog
libdwfl/dwfl_segment_report_module.c

index 76e0899e9985a2d15885c92033c255b4a30d365d..1f593ac9adc9f5d736884a730012a3a9f0c58ec9 100644 (file)
@@ -1,3 +1,8 @@
+2021-12-08  Mark Wielaard  <mark@klomp.org>
+
+       * dwfl_segment_report_module.c (dwfl_segment_report_module): Check
+       Dwfl_Module isn't associated with an Elf before installing it.
+
 2021-12-08  Mark Wielaard  <mark@klomp.org>
 
        * dwfl_segment_report_module.c (dwfl_segment_report_module): Don't
index be0aff76a92e445ef0920aedd063b68f3eb38592..f4acfe5349b3fc16904a477a361d30cc4eac09c0 100644 (file)
@@ -963,7 +963,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
        elf->flags |= ELF_F_MALLOCED;
     }
 
-  if (elf != NULL)
+  if (elf != NULL && mod->main.elf == NULL)
     {
       /* Install the file in the module.  */
       mod->main.elf = elf;