public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] objcopy memory leaks
@ 2023-02-13  2:23 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2023-02-13  2:23 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3eef3b2c2d85bb0b83a4e902d4444400ddfde0ab

commit 3eef3b2c2d85bb0b83a4e902d4444400ddfde0ab
Author: Alan Modra <amodra@gmail.com>
Date:   Sun Feb 12 22:34:27 2023 +1030

    objcopy memory leaks
    
    This fixes some objcopy memory leaks.  commit 450da4bd38ae used
    xatexit to tidy most of the hash table memory, but of course that's
    ineffective without a call to xexit.  The other major memory leak
    happens if there is an error of some sort writing the output file, due
    to not closing the input file and thus not freeing memory attached to
    the bfd.
    
            * objcopy.c (copy_file): Don't return when bfd_close of output
            gives an error, always bfd_close input too.
            (main): Call xexit.

Diff:
---
 binutils/objcopy.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index eb2e54b9602..b9d946a38e4 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3934,14 +3934,12 @@ copy_file (const char *input_filename, const char *output_filename, int ofd,
 	{
 	  status = 1;
 	  bfd_nonfatal_message (output_filename, NULL, NULL, NULL);
-	  return;
 	}
 
       if (!bfd_close (ibfd))
 	{
 	  status = 1;
 	  bfd_nonfatal_message (input_filename, NULL, NULL, NULL);
-	  return;
 	}
     }
   else
@@ -6093,5 +6091,6 @@ main (int argc, char *argv[])
 
   END_PROGRESS (program_name);
 
+  xexit (status);
   return status;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-13  2:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-13  2:23 [binutils-gdb] objcopy memory leaks 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).