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]

Re: [patch] memory leak, elflink.c


On Thu, Jul 05, 2007 at 04:37:27PM -0700, msnyder@sonic.net wrote:
> Flagged by coverity.

Didn't it flag the other two calls to callbacks->notice here?

> 2007-07-05  Michael Snyder  <msnyder@access-company.com>
> 
> 	* elflink.c (elf_link_add_object_symbols): Returns without freeing
> 	malloced memory (Coverity).

Applying this one instead.

	* elflink.c (elf_link_add_object_symbols): Return via
	error_free_vers on "notice" failure.

Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.267
diff -u -p -r1.267 elflink.c
--- bfd/elflink.c	3 Jul 2007 14:26:42 -0000	1.267
+++ bfd/elflink.c	6 Jul 2007 02:23:29 -0000
@@ -3674,8 +3674,7 @@ elf_link_add_object_symbols (bfd *abfd, 
 	 tell it that we are about to handle an as-needed lib.  */
       if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
 				       notice_as_needed))
-	return FALSE;
-
+	goto error_free_vers;
 
       /* Clone the symbol table and sym hashes.  Remember some
 	 pointers into the symbol table, and dynamic symbol count.  */
@@ -4382,7 +4381,7 @@ elf_link_add_object_symbols (bfd *abfd, 
 	 tell it that symbols added for crefs may need to be removed.  */
       if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
 				       notice_not_needed))
-	return FALSE;
+	goto error_free_vers;
 
       free (old_tab);
       objalloc_free_block ((struct objalloc *) htab->root.table.memory,
@@ -4396,7 +4395,7 @@ elf_link_add_object_symbols (bfd *abfd, 
     {
       if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
 				       notice_needed))
-	return FALSE;
+	goto error_free_vers;
       free (old_tab);
       old_tab = NULL;
     }

-- 
Alan Modra
Australia Development Lab, IBM


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