public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@vmware.com>
To: "binutils@sourceware.org" <binutils@sourceware.org>
Subject: [RFA] ar.c (move_members): Plug memory leak.
Date: Tue, 08 Mar 2011 20:20:00 -0000	[thread overview]
Message-ID: <4D768F7C.2090804@vmware.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 5 bytes --]

OK?


[-- Attachment #2: ar2.txt --]
[-- Type: text/plain, Size: 1386 bytes --]

2011-03-08  Michael Snyder  <msnyder@vmware.com>

	* ar.c (move_members): Plug memory leak.

Index: ar.c
===================================================================
RCS file: /cvs/src/src/binutils/ar.c,v
retrieving revision 1.72
diff -u -p -r1.72 ar.c
--- ar.c	8 Dec 2010 05:05:30 -0000	1.72
+++ ar.c	8 Mar 2011 20:18:42 -0000
@@ -1186,6 +1186,7 @@ move_members (bfd *arch, char **files_to
 {
   bfd **after_bfd;		/* New entries go after this one */
   bfd **current_ptr_ptr;	/* cdr pointer into contents */
+  char *tmp = NULL;
 
   for (; *files_to_move; ++files_to_move)
     {
@@ -1193,8 +1194,9 @@ move_members (bfd *arch, char **files_to
       while (*current_ptr_ptr)
 	{
 	  bfd *current_ptr = *current_ptr_ptr;
-	  if (FILENAME_CMP (normalize (*files_to_move, arch),
-			    current_ptr->filename) == 0)
+	  free (tmp);
+	  tmp = normalize (*files_to_move, arch);
+	  if (FILENAME_CMP (tmp, current_ptr->filename) == 0)
 	    {
 	      /* Move this file to the end of the list - first cut from
 		 where it is.  */
@@ -1218,10 +1220,12 @@ move_members (bfd *arch, char **files_to
       /* xgettext:c-format */
       fatal (_("no entry %s in archive %s!"), *files_to_move, arch->filename);
 
-    next_file:;
+    next_file:
+      ;
     }
 
   write_archive (arch);
+  free (tmp);
 }
 
 /* Ought to default to replacing in place, but this is existing practice!  */

             reply	other threads:[~2011-03-08 20:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-08 20:20 Michael Snyder [this message]
2011-03-25 17:14 ` Nick Clifton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D768F7C.2090804@vmware.com \
    --to=msnyder@vmware.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).