diff options
author | Alan Modra <amodra@gmail.com> | 2023-12-05 16:31:13 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-12-05 18:20:51 +1030 |
commit | 4cd766148361c2754c88e725779912f28651c559 (patch) | |
tree | 09e370c3c2d387e77c75295d0372189c9a8f9eea /bfd/elf.c | |
parent | c53b543736cd3b64adb368b0a575241a257cc003 (diff) | |
download | gdb-4cd766148361c2754c88e725779912f28651c559.zip gdb-4cd766148361c2754c88e725779912f28651c559.tar.gz gdb-4cd766148361c2754c88e725779912f28651c559.tar.bz2 |
Don't use free_contents in _bfd_elf_slurp_version_tables
In commit 7ac6d0c38c36 I made more use of free_contents in
_bfd_elf_slurp_version_tables, a variable added to tag the case where
raw verneed and verdefs have been read locally by the function, and
thus should be freed before returning. In retrospect it may have been
better to do without the extra variable entirely. It's easy to infer
when "contents" should be freed, costing a little extra on an error
path but costing less elsewhere.
* elf.c (_bfd_elf_slurp_version_tables): Don't use free_contents.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -9433,7 +9433,6 @@ bool _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver) { bfd_byte *contents = NULL; - bool free_contents = false; unsigned int freeidx = 0; size_t amt; @@ -9476,7 +9475,6 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver) if (contents == NULL) goto error_return_verref; - free_contents = true; verneed_size = hdr->sh_size; verneed_count = hdr->sh_info; } @@ -9605,7 +9603,7 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver) } elf_tdata (abfd)->cverrefs = i; - if (free_contents) + if (contents != elf_tdata (abfd)->dt_verneed) free (contents); contents = NULL; } @@ -9652,7 +9650,6 @@ _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)); @@ -9802,7 +9799,7 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver) ((bfd_byte *) everdef + iverdef->vd_next)); } - if (free_contents) + if (contents != elf_tdata (abfd)->dt_verdef) free (contents); contents = NULL; } @@ -9858,7 +9855,8 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver) return true; error_return: - if (free_contents) + if (contents != elf_tdata (abfd)->dt_verneed + && contents != elf_tdata (abfd)->dt_verdef) free (contents); return false; } |