* [binutils-gdb] asan: _bfd_elf_slurp_version_tables memory leak
@ 2023-10-25 0:44 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2023-10-25 0:44 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7ac6d0c38c365a6778a91fd37203c21561c61c4c
commit 7ac6d0c38c365a6778a91fd37203c21561c61c4c
Author: Alan Modra <amodra@gmail.com>
Date: Tue Oct 24 17:37:24 2023 +1030
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.
Diff:
---
bfd/elf.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/bfd/elf.c b/bfd/elf.c
index b5b0c69e097..bd2a5e43551 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-10-25 0:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-25 0:44 [binutils-gdb] asan: _bfd_elf_slurp_version_tables memory leak Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).