diff options
author | Nick Clifton <nickc@redhat.com> | 2018-07-20 15:05:34 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2018-07-20 15:05:34 +0100 |
commit | 3391569f218cd5d05e96769f47559d5828be3acd (patch) | |
tree | b5225952bb0f8f814014e1a1477f540f626be5d2 /binutils/dwarf.c | |
parent | 8095d2f70e1a982c006f306be1a9e1c892758914 (diff) | |
download | gdb-3391569f218cd5d05e96769f47559d5828be3acd.zip gdb-3391569f218cd5d05e96769f47559d5828be3acd.tar.gz gdb-3391569f218cd5d05e96769f47559d5828be3acd.tar.bz2 |
Close memory and resource leaks detected by coverity in the binutils directory.
* objcopy.c (add_specific_symbols): Free buffer on exit.
(add_redefine_syms_file): Close file handle on exit.
(copy_object): Close file handle on early exit.
Free buffer on early exit.
Free gaps buffers once they are no longer needed.
* dwarf.c (display_debug_frames): Free allocated memory on exit.
(load_separate_debug_info): Free allocate memory on early exit.
Diffstat (limited to 'binutils/dwarf.c')
-rw-r--r-- | binutils/dwarf.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/binutils/dwarf.c b/binutils/dwarf.c index d609df4..b6c0a3a 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -7429,10 +7429,10 @@ display_debug_frames (struct dwarf_section *section, unsigned char *start = section->start; unsigned char *end = start + section->size; unsigned char *section_start = start; - Frame_Chunk *chunks = 0, *forward_refs = 0; - Frame_Chunk *remembered_state = 0; + Frame_Chunk *chunks = NULL, *forward_refs = NULL; + Frame_Chunk *remembered_state = NULL; Frame_Chunk *rs; - int is_eh = strcmp (section->name, ".eh_frame") == 0; + bfd_boolean is_eh = strcmp (section->name, ".eh_frame") == 0; unsigned int length_return; unsigned int max_regs = 0; const char *bad_reg = _("bad register: "); @@ -8365,6 +8365,36 @@ display_debug_frames (struct dwarf_section *section, printf ("\n"); + while (remembered_state != NULL) + { + rs = remembered_state; + remembered_state = rs->next; + free (rs->col_type); + free (rs->col_offset); + rs->next = NULL; /* Paranoia. */ + free (rs); + } + + while (chunks != NULL) + { + rs = chunks; + chunks = rs->next; + free (rs->col_type); + free (rs->col_offset); + rs->next = NULL; /* Paranoia. */ + free (rs); + } + + while (forward_refs != NULL) + { + rs = forward_refs; + forward_refs = rs->next; + free (rs->col_type); + free (rs->col_offset); + rs->next = NULL; /* Paranoia. */ + free (rs); + } + return 1; } @@ -9793,6 +9823,7 @@ load_separate_debug_info (const char * main_filename, if (debugfile == NULL) { warn (_("Out of memory")); + free (canon_dir); return NULL; } |