Fix memory leak in ld ARM backend
authorThomas Preud'homme <thomas.preudhomme@arm.com>
Wed, 6 Apr 2016 08:26:42 +0000 (09:26 +0100)
committerThomas Preud'homme <thomas.preudhomme@arm.com>
Wed, 6 Apr 2016 08:28:12 +0000 (09:28 +0100)
2016-04-06  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
* elf32-arm.c (elf32_arm_size_stubs): Move error_ret_free_local to be
a fall through from error_ret_free_internal.  Free local_syms in
error_ret_free_local if allocated from bfd_elf_get_elf_syms ().

bfd/ChangeLog
bfd/elf32-arm.c

index 4fd4b4c1314aae1f84bde9a86f005372a6f0ff93..ef4254f60b637b9f162b85393f9137754342790a 100644 (file)
@@ -1,3 +1,9 @@
+2016-04-06  Thomas Preud'homme  <thomas.preudhomme@arm.com>
+
+       * elf32-arm.c (elf32_arm_size_stubs): Move error_ret_free_local to be
+       a fall through from error_ret_free_internal.  Free local_syms in
+       error_ret_free_local if allocated from bfd_elf_get_elf_syms ().
+
 2016-04-05  Cupertino Miranda  <cmiranda@synopsys.com>
 
        * elf32-arc.c (plt_do_relocs_for_symbol): Changed.
index 81ebf67a3af03d82e4c34a9ad5112f2dbe55fe55..1d506f69fddfc57ed6ca8860bb87b24f091e3918 100644 (file)
@@ -5294,7 +5294,13 @@ elf32_arm_size_stubs (bfd *output_bfd,
                    error_ret_free_internal:
                      if (elf_section_data (section)->relocs == NULL)
                        free (internal_relocs);
-                     goto error_ret_free_local;
+                   /* Fall through.  */
+                   error_ret_free_local:
+                     if (local_syms != NULL
+                         && (symtab_hdr->contents
+                             != (unsigned char *) local_syms))
+                       free (local_syms);
+                     return FALSE;
                    }
 
                  hash = NULL;
@@ -5700,9 +5706,6 @@ elf32_arm_size_stubs (bfd *output_bfd,
       htab->num_a8_erratum_fixes = 0;
     }
   return TRUE;
-
- error_ret_free_local:
-  return FALSE;
 }
 
 /* Build all the stubs associated with the current output file.  The