aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-08-22 16:44:45 +0000
committerTom Tromey <tromey@redhat.com>2012-08-22 16:44:45 +0000
commite1507e953ec06f50f83f0bbc2b50a7f3b11f4022 (patch)
tree3d41d055dcf029eefad47eb986ad8559430e1740 /gdb/symfile.c
parent1c00ec6b06aa852351b7eebd64b4f1604766e818 (diff)
downloadgdb-e1507e953ec06f50f83f0bbc2b50a7f3b11f4022.zip
gdb-e1507e953ec06f50f83f0bbc2b50a7f3b11f4022.tar.gz
gdb-e1507e953ec06f50f83f0bbc2b50a7f3b11f4022.tar.bz2
* jit.c (jit_object_close_impl): Don't malloc the objfile
name. * objfiles.c (allocate_objfile): Don't malloc the objfile name. (free_objfile): Don't free the objfile name. * objfiles.h (struct objfile) <name>: Update comment. * symfile.c (reread_symbols): Fix reference counting. Don't malloc objfile name.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 7c202b5..a07f84c 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2506,9 +2506,7 @@ reread_symbols (void)
clear_objfile_data (objfile);
- /* Clean up any state BFD has sitting around. We don't need
- to close the descriptor but BFD lacks a way of closing the
- BFD without closing the descriptor. */
+ /* Clean up any state BFD has sitting around. */
{
struct bfd *obfd = objfile->obfd;
@@ -2516,11 +2514,18 @@ reread_symbols (void)
/* Open the new BFD before freeing the old one, so that
the filename remains live. */
objfile->obfd = gdb_bfd_open_maybe_remote (obfd_filename);
+ if (objfile->obfd == NULL)
+ {
+ /* We have to make a cleanup and error here, rather
+ than erroring later, because once we unref OBFD,
+ OBFD_FILENAME will be freed. */
+ make_cleanup_bfd_unref (obfd);
+ error (_("Can't open %s to read symbols."), obfd_filename);
+ }
gdb_bfd_unref (obfd);
}
- if (objfile->obfd == NULL)
- error (_("Can't open %s to read symbols."), objfile->name);
+ objfile->name = bfd_get_filename (objfile->obfd);
/* bfd_openr sets cacheable to true, which is what we want. */
if (!bfd_check_format (objfile->obfd, bfd_object))
error (_("Can't read symbols from %s: %s."), objfile->name,