aboutsummaryrefslogtreecommitdiff
path: root/bfd/coffgen.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-11-01 11:35:42 +0000
committerNick Clifton <nickc@redhat.com>2017-11-01 11:35:42 +0000
commitee357486aa87b17782111295c5e7bd4ac9e6970f (patch)
tree26750ac53e7ea4c06e31a9230d11fce21678126f /bfd/coffgen.c
parent4070243b5c1f66a36dd43a7b722e991ac9fc40e1 (diff)
downloadgdb-ee357486aa87b17782111295c5e7bd4ac9e6970f.zip
gdb-ee357486aa87b17782111295c5e7bd4ac9e6970f.tar.gz
gdb-ee357486aa87b17782111295c5e7bd4ac9e6970f.tar.bz2
Fix an invalid free called when attempting to link a COFF object against an ELF archive with --no-keep-memory enabled.
PR 22369 * coffgen.c (_bfd_coff_free_symbols): Fail if called on a non-COFF file. * cofflink.c (coff_link_check_archive_element): Skip non-COFF members of an archive.
Diffstat (limited to 'bfd/coffgen.c')
-rw-r--r--bfd/coffgen.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index d7cdf8f..98363d0 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -1659,7 +1659,6 @@ _bfd_coff_get_external_symbols (bfd *abfd)
}
obj_coff_external_syms (abfd) = syms;
-
return TRUE;
}
@@ -1747,12 +1746,16 @@ _bfd_coff_read_string_table (bfd *abfd)
bfd_boolean
_bfd_coff_free_symbols (bfd *abfd)
{
+ if (! bfd_family_coff (abfd))
+ return FALSE;
+
if (obj_coff_external_syms (abfd) != NULL
&& ! obj_coff_keep_syms (abfd))
{
free (obj_coff_external_syms (abfd));
obj_coff_external_syms (abfd) = NULL;
}
+
if (obj_coff_strings (abfd) != NULL
&& ! obj_coff_keep_strings (abfd))
{
@@ -1760,6 +1763,7 @@ _bfd_coff_free_symbols (bfd *abfd)
obj_coff_strings (abfd) = NULL;
obj_coff_strings_len (abfd) = 0;
}
+
return TRUE;
}