diff options
author | Alan Modra <amodra@gmail.com> | 2023-01-08 12:56:21 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-01-10 10:09:11 +1030 |
commit | 8eacd95dd4406ae4021a6996c0c505648da75440 (patch) | |
tree | 4a3e07d38921686be6f11f0e678c40504172e589 /bfd | |
parent | 10c386190cb8dcc398292b6053d5fbf6bfd3a4ff (diff) | |
download | gdb-8eacd95dd4406ae4021a6996c0c505648da75440.zip gdb-8eacd95dd4406ae4021a6996c0c505648da75440.tar.gz gdb-8eacd95dd4406ae4021a6996c0c505648da75440.tar.bz2 |
Set dwarf2 stash pointer earlier
This fixes a memory leak in the vanishingly rare cases (found by
fuzzers of course) when something goes wrong in the save_section_vma,
htab_create_alloc or alloc_trie_leaf calls before *pinfo is written.
If *pinfo is not written, _bfd_dwarf2_cleanup_debug_info won't be able
to free that memory.
* dwarf2.c (_bfd_dwarf2_slurp_debug_info): Save stash pointer
on setting up stash.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/dwarf2.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index f689eeb..bd43180 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -5408,6 +5408,7 @@ _bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd, stash = (struct dwarf2_debug *) bfd_zalloc (abfd, amt); if (! stash) return false; + *pinfo = stash; } stash->orig_bfd = abfd; stash->debug_sections = debug_sections; @@ -5433,8 +5434,6 @@ _bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd, if (!stash->alt.trie_root) return false; - *pinfo = stash; - if (debug_bfd == NULL) debug_bfd = abfd; |