diff options
author | Alan Modra <amodra@gmail.com> | 2023-10-24 17:37:24 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-10-25 11:12:11 +1030 |
commit | 7ac6d0c38c365a6778a91fd37203c21561c61c4c (patch) | |
tree | acf6d1da0ba0777bd1188be1d22819bf1cc11414 /bfd | |
parent | 220be060180d14a0512bfb39b22341a7368822ae (diff) | |
download | gdb-7ac6d0c38c365a6778a91fd37203c21561c61c4c.zip gdb-7ac6d0c38c365a6778a91fd37203c21561c61c4c.tar.gz gdb-7ac6d0c38c365a6778a91fd37203c21561c61c4c.tar.bz2 |
asan: _bfd_elf_slurp_version_tables memory leak
Extends commit 6136093c0d00 to handle verdefs as well as verrefs.
PR 30886
* elf.c (_bfd_elf_slurp_version_tables): See free_contents for
verdefs too. Use free_contents rather than elf_tdata fields.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/elf.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -9571,7 +9571,7 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver) } elf_tdata (abfd)->cverrefs = i; - if (elf_tdata (abfd)->dt_verneed == NULL) + if (free_contents) free (contents); contents = NULL; } @@ -9618,6 +9618,7 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver) if (contents == NULL) goto error_return_verdef; + free_contents = true; BFD_ASSERT (sizeof (Elf_External_Verdef) >= sizeof (Elf_External_Verdaux)); @@ -9767,7 +9768,7 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver) ((bfd_byte *) everdef + iverdef->vd_next)); } - if (elf_tdata (abfd)->dt_verdef == NULL) + if (free_contents) free (contents); contents = NULL; } |