forked from Imagelibrary/binutils-gdb
Use gdb_bfd_ref_ptr in objfile
This changes struct objfile to use a gdb_bfd_ref_ptr. In addition to removing some manual memory management, this fixes a use-after-free that was introduced by the registry rewrite series. The issue there was that, in some cases, registry shutdown could refer to memory that had already been freed. This help fix the bug by delaying the destruction of the BFD reference (and thus the per-bfd object) until after the registry has been shut down.
This commit is contained in:
@@ -858,7 +858,7 @@ auto_load_objfile_script (struct objfile *objfile,
|
||||
{
|
||||
unsigned long crc32;
|
||||
gdb::unique_xmalloc_ptr<char> debuglink
|
||||
(bfd_get_debug_link_info (parent->obfd, &crc32));
|
||||
(bfd_get_debug_link_info (parent->obfd.get (), &crc32));
|
||||
|
||||
if (debuglink.get () != nullptr
|
||||
&& strcmp (debuglink.get (), lbasename (realname.get ())) != 0)
|
||||
@@ -1119,7 +1119,7 @@ source_section_scripts (struct objfile *objfile, const char *section_name,
|
||||
static void
|
||||
auto_load_section_scripts (struct objfile *objfile, const char *section_name)
|
||||
{
|
||||
bfd *abfd = objfile->obfd;
|
||||
bfd *abfd = objfile->obfd.get ();
|
||||
asection *scripts_sect;
|
||||
bfd_byte *data = NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user