PR29925, Memory leak in find_abstract_instance
authorAlan Modra <amodra@gmail.com>
Wed, 21 Dec 2022 11:10:12 +0000 (21:40 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 21 Dec 2022 20:33:07 +0000 (07:03 +1030)
commitd28fbc7197ba0e021a43f873eff90b05dcdcff6a
tree7957b5ecb763fec5d5822917c84dfb376ec4af9f
parentf7cb9bba3d5d8dc10d4cccc42c67a4ba33820ddc
PR29925, Memory leak in find_abstract_instance

The testcase in the PR had a variable with both DW_AT_decl_file and
DW_AT_specification, where the DW_AT_specification also specified
DW_AT_decl_file.  This leads to a memory leak as the file name is
malloced and duplicates are not expected.

I've also changed find_abstract_instance to not use a temp for "name",
because that can result in a change in behaviour from the usual last
of duplicate attributes wins.

PR 29925
* dwarf2.c (find_abstract_instance): Delete "name" variable.
Free *filename_ptr before assigning new file name.
(scan_unit_for_symbols): Similarly free func->file and
var->file before assigning.
bfd/dwarf2.c