mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-25 21:41:47 +08:00
Fix PowerPC targets minor memory leaks found by Coverity
bfd/ 2014-02-04 Jan Kratochvil <jan.kratochvil@redhat.com> * coff-rs6000.c (xcoff_write_archive_contents_big): Free OFFSETS in return paths. Three times. * elf64-ppc.c (ppc64_elf_link_hash_table_create): Free HTAB in all return paths. (ppc64_elf_tls_optimize): Free TOC_REF in return path. (ppc64_elf_edit_toc): Free USED in return path.
This commit is contained in:
@ -1,3 +1,12 @@
|
|||||||
|
2014-02-04 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
|
* coff-rs6000.c (xcoff_write_archive_contents_big): Free OFFSETS in
|
||||||
|
return paths. Three times.
|
||||||
|
* elf64-ppc.c (ppc64_elf_link_hash_table_create): Free HTAB in all
|
||||||
|
return paths.
|
||||||
|
(ppc64_elf_tls_optimize): Free TOC_REF in return path.
|
||||||
|
(ppc64_elf_edit_toc): Free USED in return path.
|
||||||
|
|
||||||
2014-02-03 Sandra Loosemore <sandra@codesourcery.com>
|
2014-02-03 Sandra Loosemore <sandra@codesourcery.com>
|
||||||
|
|
||||||
* reloc.c (BFD_RELOC_NIOS2_GOT_LO, BFD_RELOC_NIOS2_GOT_HA): New.
|
* reloc.c (BFD_RELOC_NIOS2_GOT_LO, BFD_RELOC_NIOS2_GOT_HA): New.
|
||||||
|
@ -2404,7 +2404,10 @@ xcoff_write_archive_contents_big (bfd *abfd)
|
|||||||
PRINT20 (ahdrp->nextoff, iterator.next.offset);
|
PRINT20 (ahdrp->nextoff, iterator.next.offset);
|
||||||
|
|
||||||
if (!do_pad (abfd, iterator.current.leading_padding))
|
if (!do_pad (abfd, iterator.current.leading_padding))
|
||||||
return FALSE;
|
{
|
||||||
|
free (offsets);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
BFD_ASSERT (iterator.current.offset == bfd_tell (abfd));
|
BFD_ASSERT (iterator.current.offset == bfd_tell (abfd));
|
||||||
namlen = iterator.current.padded_namlen;
|
namlen = iterator.current.padded_namlen;
|
||||||
@ -2414,7 +2417,10 @@ xcoff_write_archive_contents_big (bfd *abfd)
|
|||||||
|| bfd_seek (iterator.current.member, 0, SEEK_SET) != 0
|
|| bfd_seek (iterator.current.member, 0, SEEK_SET) != 0
|
||||||
|| !do_copy (abfd, iterator.current.member)
|
|| !do_copy (abfd, iterator.current.member)
|
||||||
|| !do_pad (abfd, iterator.current.trailing_padding))
|
|| !do_pad (abfd, iterator.current.trailing_padding))
|
||||||
return FALSE;
|
{
|
||||||
|
free (offsets);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
offsets[i] = iterator.current.offset;
|
offsets[i] = iterator.current.offset;
|
||||||
prevoff = iterator.current.offset;
|
prevoff = iterator.current.offset;
|
||||||
@ -2459,7 +2465,10 @@ xcoff_write_archive_contents_big (bfd *abfd)
|
|||||||
member_table_size += member_table_size & 1;
|
member_table_size += member_table_size & 1;
|
||||||
member_table = bfd_zmalloc (member_table_size);
|
member_table = bfd_zmalloc (member_table_size);
|
||||||
if (member_table == NULL)
|
if (member_table == NULL)
|
||||||
return FALSE;
|
{
|
||||||
|
free (offsets);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
hdr = (struct xcoff_ar_hdr_big *) member_table;
|
hdr = (struct xcoff_ar_hdr_big *) member_table;
|
||||||
|
|
||||||
|
@ -4168,19 +4168,31 @@ ppc64_elf_link_hash_table_create (bfd *abfd)
|
|||||||
/* Init the stub hash table too. */
|
/* Init the stub hash table too. */
|
||||||
if (!bfd_hash_table_init (&htab->stub_hash_table, stub_hash_newfunc,
|
if (!bfd_hash_table_init (&htab->stub_hash_table, stub_hash_newfunc,
|
||||||
sizeof (struct ppc_stub_hash_entry)))
|
sizeof (struct ppc_stub_hash_entry)))
|
||||||
return NULL;
|
{
|
||||||
|
_bfd_elf_link_hash_table_free ((struct bfd_link_hash_table *) htab);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* And the branch hash table. */
|
/* And the branch hash table. */
|
||||||
if (!bfd_hash_table_init (&htab->branch_hash_table, branch_hash_newfunc,
|
if (!bfd_hash_table_init (&htab->branch_hash_table, branch_hash_newfunc,
|
||||||
sizeof (struct ppc_branch_hash_entry)))
|
sizeof (struct ppc_branch_hash_entry)))
|
||||||
return NULL;
|
{
|
||||||
|
bfd_hash_table_free (&htab->stub_hash_table);
|
||||||
|
_bfd_elf_link_hash_table_free ((struct bfd_link_hash_table *) htab);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
htab->tocsave_htab = htab_try_create (1024,
|
htab->tocsave_htab = htab_try_create (1024,
|
||||||
tocsave_htab_hash,
|
tocsave_htab_hash,
|
||||||
tocsave_htab_eq,
|
tocsave_htab_eq,
|
||||||
NULL);
|
NULL);
|
||||||
if (htab->tocsave_htab == NULL)
|
if (htab->tocsave_htab == NULL)
|
||||||
return NULL;
|
{
|
||||||
|
bfd_hash_table_free (&htab->branch_hash_table);
|
||||||
|
bfd_hash_table_free (&htab->stub_hash_table);
|
||||||
|
_bfd_elf_link_hash_table_free ((struct bfd_link_hash_table *) htab);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Initializing two fields of the union is just cosmetic. We really
|
/* Initializing two fields of the union is just cosmetic. We really
|
||||||
only care about glist, but when compiled on a 32-bit host the
|
only care about glist, but when compiled on a 32-bit host the
|
||||||
@ -8073,7 +8085,10 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info)
|
|||||||
relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL,
|
relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL,
|
||||||
info->keep_memory);
|
info->keep_memory);
|
||||||
if (relstart == NULL)
|
if (relstart == NULL)
|
||||||
return FALSE;
|
{
|
||||||
|
free (toc_ref);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
relend = relstart + sec->reloc_count;
|
relend = relstart + sec->reloc_count;
|
||||||
for (rel = relstart; rel < relend; rel++)
|
for (rel = relstart; rel < relend; rel++)
|
||||||
@ -8781,7 +8796,10 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
|
|||||||
relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL,
|
relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL,
|
||||||
info->keep_memory);
|
info->keep_memory);
|
||||||
if (relstart == NULL)
|
if (relstart == NULL)
|
||||||
goto error_ret;
|
{
|
||||||
|
free (used);
|
||||||
|
goto error_ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Mark toc entries referenced as used. */
|
/* Mark toc entries referenced as used. */
|
||||||
do
|
do
|
||||||
|
Reference in New Issue
Block a user