mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-28 14:08:09 +08:00
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:
@ -157,7 +157,7 @@ objfpy_get_build_id (PyObject *self, void *closure)
|
||||
|
||||
try
|
||||
{
|
||||
build_id = build_id_bfd_get (objfile->obfd);
|
||||
build_id = build_id_bfd_get (objfile->obfd.get ());
|
||||
}
|
||||
catch (const gdb_exception &except)
|
||||
{
|
||||
@ -448,7 +448,7 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
gdb_bfd_ref_ptr abfd (symfile_bfd_open (file_name));
|
||||
|
||||
symbol_file_add_separate (abfd.get (), file_name, 0, obj->objfile);
|
||||
symbol_file_add_separate (abfd, file_name, 0, obj->objfile);
|
||||
}
|
||||
catch (const gdb_exception &except)
|
||||
{
|
||||
@ -625,7 +625,7 @@ objfpy_lookup_objfile_by_build_id (const char *build_id)
|
||||
/* Don't return separate debug files. */
|
||||
if (objfile->separate_debug_objfile_backlink != NULL)
|
||||
continue;
|
||||
obfd_build_id = build_id_bfd_get (objfile->obfd);
|
||||
obfd_build_id = build_id_bfd_get (objfile->obfd.get ());
|
||||
if (obfd_build_id == NULL)
|
||||
continue;
|
||||
if (objfpy_build_id_matches (obfd_build_id, build_id))
|
||||
|
Reference in New Issue
Block a user