aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2025-01-01 22:52:06 +1030
committerAlan Modra <amodra@gmail.com>2025-01-01 22:52:06 +1030
commit4739b9137e1fe1cfaf2e0de6924c122035942b26 (patch)
tree25ade2d868896b772fc4c80f32bb7a8285cc9a4a /binutils
parentd58fbef40d70057b83d3773aa409b402236a7e62 (diff)
downloadgdb-4739b9137e1fe1cfaf2e0de6924c122035942b26.zip
gdb-4739b9137e1fe1cfaf2e0de6924c122035942b26.tar.gz
gdb-4739b9137e1fe1cfaf2e0de6924c122035942b26.tar.bz2
Close elements of output archive
When cleaning up an archive, close all its elements. This fixes a number of ar memory leaks. bfd/ * archive.c (_bfd_archive_close_and_cleanup): Close elements of an archive open for writing. binutils/ * objcopy.c (copy_archive): Don't close output archive elements here. * dlltool.c (gen_lib_file): Likewise. ld/ * pe-dll.c (pe_dll_generate_implib): Don't close output archive elements here.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/dlltool.c7
-rw-r--r--binutils/objcopy.c5
2 files changed, 1 insertions, 11 deletions
diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index 4426aae..d32bf20 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -3009,13 +3009,6 @@ gen_lib_file (int delay)
if (! bfd_close (outarch))
bfd_fatal (imp_name);
- while (head != NULL)
- {
- bfd *n = head->archive_next;
- bfd_close (head);
- head = n;
- }
-
/* Delete all the temp files. */
unlink_temp_files ();
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 10539ed..f644176 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3845,10 +3845,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
if (l->obfd == NULL)
rmdir (l->name);
else
- {
- bfd_close (l->obfd);
- unlink (l->name);
- }
+ unlink (l->name);
free (l->name);
}
next = l->next;