* opncls.c (bfd_close): Until BFD_IN_MEMORY has an iovec,
authorDoug Evans <dje@google.com>
Sun, 16 Aug 2009 17:32:35 +0000 (17:32 +0000)
committerDoug Evans <dje@google.com>
Sun, 16 Aug 2009 17:32:35 +0000 (17:32 +0000)
at least don't leak memory.

bfd/ChangeLog
bfd/opncls.c

index ecca9ca072d62e8813d4c66b4b88823513892933..f9c4c6de077f89e9a1188575451cffb50af81cbb 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-16  Doug Evans  <dje@google.com>
+
+       * opncls.c (bfd_close): Until BFD_IN_MEMORY has an iovec,
+       at least don't leak memory.
+
 2009-08-13  DJ Delorie  <dj@redhat.com>
 
        * elf32-m32c.c (m32c_elf_relax_delete_bytes): Adjust symbol sizes
index 6a4f319d3156f4ea200a91ff9ec60b584cff4173..799203065ce3a44e98372b139c3458ed6bf300b1 100644 (file)
@@ -703,12 +703,18 @@ bfd_close (bfd *abfd)
   if (! BFD_SEND (abfd, _close_and_cleanup, (abfd)))
     return FALSE;
 
-  /* FIXME: cagney/2004-02-15: Need to implement a BFD_IN_MEMORY io
-     vector.  */
-  if (!(abfd->flags & BFD_IN_MEMORY))
-    ret = abfd->iovec->bclose (abfd);
+  if ((abfd->flags & BFD_IN_MEMORY) != 0)
+    {
+      /* FIXME: cagney/2004-02-15: Need to implement a BFD_IN_MEMORY io
+        vector.
+        Until that's done, at least don't leak memory.  */
+      struct bfd_in_memory *bim = abfd->iostream;
+      free (bim->buffer);
+      free (bim);
+      ret = TRUE;
+    }
   else
-    ret = TRUE;
+    ret = abfd->iovec->bclose (abfd);
 
   if (ret)
     _maybe_make_executable (abfd);