This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] objcopy: Close some memory leaks in error paths


I don't know if we care greatly about memory leaks on error paths,
especially in objcopy where we'll certainly be about to exit, but
given that I spotted these I thought I'd post this patch.

---

Closes some memory leaks within objcopy for error paths.

binutils/ChangeLog:

	* objcopy.c (copy_section): Add extra calls to free for error
	paths.
---
 binutils/ChangeLog | 5 +++++
 binutils/objcopy.c | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 1821c0c..d40cfcb 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3375,6 +3375,7 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
 	{
 	  status = 1;
 	  bfd_nonfatal_message (NULL, ibfd, isection, NULL);
+	  free (memhunk);
 	  return;
 	}
 
@@ -3428,6 +3429,7 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
 	{
 	  status = 1;
 	  bfd_nonfatal_message (NULL, obfd, osection, NULL);
+	  free (memhunk);
 	  return;
 	}
       free (memhunk);
@@ -3449,6 +3451,7 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
 	{
 	  status = 1;
 	  bfd_nonfatal_message (NULL, obfd, osection, NULL);
+	  free (memhunk);
 	  return;
 	}
       free (memhunk);
-- 
2.6.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]