diff options
author | Tom Tromey <tom@tromey.com> | 2022-08-02 09:55:32 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-08-03 13:26:58 -0600 |
commit | 98badbfdc222d1d7f346046f23a64522b88d22a0 (patch) | |
tree | a57a95b75f64a0e318e0b1bd31dd6b246e4797d8 /gdb/python/py-objfile.c | |
parent | 4d44946794e68cf79cfba467fa414a958dba2185 (diff) | |
download | binutils-98badbfdc222d1d7f346046f23a64522b88d22a0.zip binutils-98badbfdc222d1d7f346046f23a64522b88d22a0.tar.gz binutils-98badbfdc222d1d7f346046f23a64522b88d22a0.tar.bz2 |
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.
Diffstat (limited to 'gdb/python/py-objfile.c')
-rw-r--r-- | gdb/python/py-objfile.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index 4cc5702..757f9aa 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -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)) |