diff options
author | Nick Clifton <nickc@redhat.com> | 2018-07-25 10:56:45 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2018-07-25 10:56:45 +0100 |
commit | e3d39609d16dccfef8fd1f02090fcd1df82736df (patch) | |
tree | 1399c03846e9db283a88eabedf40a28ef397c802 /binutils/rddbg.c | |
parent | 491993044ba6cfb2b0fc93c8b3032d5c91cccda5 (diff) |
Fix potential memory leaks in some of the binutils source files.
* rdcoff.c (parse_coff_struct_type): Free fields array upon early
exit.
(parse_coff_enum_type): Free names and vals arrays upon early
exit.
* rddbg.c (read_section_stabs_debugging_info): Free shandle and
strings and stabs arrays upon early exit.
* readelf.c (get_32bit_section_headers): Free shdrs structure upon
early exit.
(get_64bit_section_headers): Likewise.
(get_32bit_elf_symbols): Generate an error if multiple symbol
table index sections are associated with the same symbol section.
(get_64bit_elf_symbols): Likewise.
(process_dynamic_section): Generate an error if there are multiple
dynamic symbol table sections, multiple dynamic string tables or
multiple dynamic symbol information sections.
Diffstat (limited to 'binutils/rddbg.c')
-rw-r--r-- | binutils/rddbg.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/binutils/rddbg.c b/binutils/rddbg.c index 4a690f6282..2a238737bb 100644 --- a/binutils/rddbg.c +++ b/binutils/rddbg.c @@ -128,6 +128,8 @@ read_section_stabs_debugging_info (bfd *abfd, asymbol **syms, long symcount, fprintf (stderr, "%s: %s: %s\n", bfd_get_filename (abfd), names[i].secname, bfd_errmsg (bfd_get_error ())); + free (shandle); + free (stabs); return FALSE; } @@ -138,6 +140,9 @@ read_section_stabs_debugging_info (bfd *abfd, asymbol **syms, long symcount, fprintf (stderr, "%s: %s: %s\n", bfd_get_filename (abfd), names[i].strsecname, bfd_errmsg (bfd_get_error ())); + free (shandle); + free (strings); + free (stabs); return FALSE; } /* Zero terminate the strings table, just in case. */ @@ -146,7 +151,11 @@ read_section_stabs_debugging_info (bfd *abfd, asymbol **syms, long symcount, { shandle = start_stab (dhandle, abfd, TRUE, syms, symcount); if (shandle == NULL) - return FALSE; + { + free (strings); + free (stabs); + return FALSE; + } } *pfound = TRUE; @@ -213,17 +222,16 @@ read_section_stabs_debugging_info (bfd *abfd, asymbol **syms, long symcount, (long) (stab - stabs) / 12); break; } - else - s = concat (s, (char *) strings + strx, - (const char *) NULL); + + s = concat (s, (char *) strings + strx, + (const char *) NULL); /* We have to restore the backslash, because, if the linker is hashing stabs strings, we may see the same string more than once. */ *p = '\\'; - if (f != NULL) - free (f); + free (f); f = s; } @@ -233,6 +241,10 @@ read_section_stabs_debugging_info (bfd *abfd, asymbol **syms, long symcount, { stab_context (); free_saved_stabs (); + free (f); + free (shandle); + free (stabs); + free (strings); return FALSE; } |