aboutsummaryrefslogtreecommitdiff
path: root/binutils/dwarf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-01-13 22:30:46 +1030
committerAlan Modra <amodra@gmail.com>2020-01-13 22:45:36 +1030
commita788aedd86da983faf0afef3cb41461118a2e9f2 (patch)
tree013d34de70329b9930b0b8f46f1418b32803c7a3 /binutils/dwarf.c
parent805f38bc551de820bcd7b31d3c5731ae27cf853a (diff)
downloadgdb-a788aedd86da983faf0afef3cb41461118a2e9f2.zip
gdb-a788aedd86da983faf0afef3cb41461118a2e9f2.tar.gz
gdb-a788aedd86da983faf0afef3cb41461118a2e9f2.tar.bz2
PR23560, PR23561, readelf memory leaks
PR 23560 PR 23561 * dwarf.c (display_debug_frames): Move fde_fc earlier. Free fde_fc col_type and col_offset. * readelf.c (apply_relocations): Move symsec check earlier. (free_debug_section): Free reloc_info. (process_notes_at): Free pnotes on error path. (process_object): Free dump_sects here.. (process_archive): ..not here.
Diffstat (limited to 'binutils/dwarf.c')
-rw-r--r--binutils/dwarf.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 9c96f47..35842f7 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -7801,6 +7801,7 @@ display_debug_frames (struct dwarf_section *section,
unsigned int offset_size;
unsigned int initial_length_size;
bfd_boolean all_nops;
+ static Frame_Chunk fde_fc;
saved_start = start;
@@ -7898,7 +7899,6 @@ display_debug_frames (struct dwarf_section *section,
else
{
unsigned char *look_for;
- static Frame_Chunk fde_fc;
unsigned long segment_selector;
if (is_eh)
@@ -8705,6 +8705,17 @@ display_debug_frames (struct dwarf_section *section,
if (do_debug_frames_interp && ! all_nops)
frame_display_row (fc, &need_col_headers, &max_regs);
+ if (fde_fc.col_type != NULL)
+ {
+ free (fde_fc.col_type);
+ fde_fc.col_type = NULL;
+ }
+ if (fde_fc.col_offset != NULL)
+ {
+ free (fde_fc.col_offset);
+ fde_fc.col_offset = NULL;
+ }
+
start = block_end;
eh_addr_size = saved_eh_addr_size;
}