mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-18 00:32:30 +08:00
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.
This commit is contained in:
@ -1,3 +1,13 @@
|
|||||||
|
2018-07-20 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2018-07-20 Chenghua Xu <paul.hua.gm@gmail.com>
|
2018-07-20 Chenghua Xu <paul.hua.gm@gmail.com>
|
||||||
Maciej W. Rozycki <macro@mips.com>
|
Maciej W. Rozycki <macro@mips.com>
|
||||||
|
|
||||||
|
@ -7429,10 +7429,10 @@ display_debug_frames (struct dwarf_section *section,
|
|||||||
unsigned char *start = section->start;
|
unsigned char *start = section->start;
|
||||||
unsigned char *end = start + section->size;
|
unsigned char *end = start + section->size;
|
||||||
unsigned char *section_start = start;
|
unsigned char *section_start = start;
|
||||||
Frame_Chunk *chunks = 0, *forward_refs = 0;
|
Frame_Chunk *chunks = NULL, *forward_refs = NULL;
|
||||||
Frame_Chunk *remembered_state = 0;
|
Frame_Chunk *remembered_state = NULL;
|
||||||
Frame_Chunk *rs;
|
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 length_return;
|
||||||
unsigned int max_regs = 0;
|
unsigned int max_regs = 0;
|
||||||
const char *bad_reg = _("bad register: ");
|
const char *bad_reg = _("bad register: ");
|
||||||
@ -8365,6 +8365,36 @@ display_debug_frames (struct dwarf_section *section,
|
|||||||
|
|
||||||
printf ("\n");
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9793,6 +9823,7 @@ load_separate_debug_info (const char * main_filename,
|
|||||||
if (debugfile == NULL)
|
if (debugfile == NULL)
|
||||||
{
|
{
|
||||||
warn (_("Out of memory"));
|
warn (_("Out of memory"));
|
||||||
|
free (canon_dir);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1142,6 +1142,8 @@ add_specific_symbols (const char *filename, htab_t htab)
|
|||||||
line = eol;
|
line = eol;
|
||||||
line_count ++;
|
line_count ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See whether a symbol should be stripped or kept
|
/* See whether a symbol should be stripped or kept
|
||||||
@ -1817,6 +1819,7 @@ add_redefine_syms_file (const char *filename)
|
|||||||
fatal (_("%s:%d: premature end of file"), filename, lineno);
|
fatal (_("%s:%d: premature end of file"), filename, lineno);
|
||||||
|
|
||||||
free (buf);
|
free (buf);
|
||||||
|
fclose (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy unknown object file IBFD onto OBFD.
|
/* Copy unknown object file IBFD onto OBFD.
|
||||||
@ -2823,6 +2826,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
|
|||||||
pdump->filename,
|
pdump->filename,
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
free (contents);
|
free (contents);
|
||||||
|
fclose (f);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3153,6 +3157,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
|
|||||||
off, now))
|
off, now))
|
||||||
{
|
{
|
||||||
bfd_nonfatal_message (NULL, obfd, osections[i], NULL);
|
bfd_nonfatal_message (NULL, obfd, osections[i], NULL);
|
||||||
|
free (buf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3161,6 +3166,10 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
free (gaps);
|
||||||
|
gaps = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allow the BFD backend to copy any private data it understands
|
/* Allow the BFD backend to copy any private data it understands
|
||||||
|
Reference in New Issue
Block a user