diff options
author | Alan Modra <amodra@gmail.com> | 2020-07-15 10:59:20 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-07-15 19:47:57 +0930 |
commit | 28b80303a2f3e47fcedcfab677a322a8e71dc607 (patch) | |
tree | 468617d3fc11392e815232dd83de1f15c1fa2a1e /bfd | |
parent | 4fd8d5856435ff84de1f181381fc51754285af6f (diff) | |
download | gdb-28b80303a2f3e47fcedcfab677a322a8e71dc607.zip gdb-28b80303a2f3e47fcedcfab677a322a8e71dc607.tar.gz gdb-28b80303a2f3e47fcedcfab677a322a8e71dc607.tar.bz2 |
PR26239, memory leak in _bfd_dwarf2_slurp_debug_info
PR 26239
* coffgen.c (_bfd_coff_close_and_cleanup): Free dwarf2 info.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/coffgen.c | 14 |
2 files changed, 15 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 1337645..6532c53 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2020-07-15 Alan Modra <amodra@gmail.com> + + PR 26239 + * coffgen.c (_bfd_coff_close_and_cleanup): Free dwarf2 info. + 2020-07-15 Nick Clifton <nickc@redhat.com> PR26240 diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 0a26972..c14e9db 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -3141,16 +3141,22 @@ bfd_coff_group_name (bfd *abfd, const asection *sec) bfd_boolean _bfd_coff_close_and_cleanup (bfd *abfd) { - if (abfd->format == bfd_object - && bfd_family_coff (abfd) - && coff_data (abfd) != NULL) + struct coff_tdata *tdata = coff_data (abfd); + + if (tdata != NULL) { /* PR 25447: Do not clear the keep_syms and keep_strings flags. These may have been set by pe_ILF_build_a_bfd() indicating that the syms and strings pointers are not to be freed. */ - if (!_bfd_coff_free_symbols (abfd)) + if (bfd_get_format (abfd) == bfd_object + && bfd_family_coff (abfd) + && !_bfd_coff_free_symbols (abfd)) return FALSE; + + if (bfd_get_format (abfd) == bfd_object + || bfd_get_format (abfd) == bfd_core) + _bfd_dwarf2_cleanup_debug_info (abfd, &tdata->dwarf2_find_line_info); } return _bfd_generic_close_and_cleanup (abfd); } |