Replace "if (x) free (x)" with "free (x)", bfd

* aoutx.h: Replace "if (x) free (x)" with "free (x)" throughout.
	* archive.c, * bfd.c, * bfdio.c, * coff-alpha.c, * coff-ppc.c,
	* coff-sh.c, * coff-stgo32.c, * coffcode.h, * coffgen.c,
	* cofflink.c, * cpu-arm.c, * doc/chew.c, * dwarf2.c, * ecoff.c,
	* ecofflink.c, * elf-eh-frame.c, * elf-m10200.c, * elf-m10300.c,
	* elf-strtab.c, * elf.c, * elf32-arc.c, * elf32-arm.c,
	* elf32-avr.c, * elf32-bfin.c, * elf32-cr16.c, * elf32-crx.c,
	* elf32-epiphany.c, * elf32-ft32.c, * elf32-h8300.c,
	* elf32-ip2k.c, * elf32-m32c.c, * elf32-m68hc11.c,
	* elf32-m68k.c, * elf32-microblaze.c, * elf32-msp430.c,
	* elf32-nds32.c, * elf32-nios2.c, * elf32-ppc.c, * elf32-pru.c,
	* elf32-rl78.c, * elf32-rx.c, * elf32-sh.c, * elf32-spu.c,
	* elf32-v850.c, * elf32-xtensa.c, * elf64-alpha.c,
	* elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mips.c
	* elf64-mmix.c, * elf64-ppc.c, * elf64-sparc.c, * elfcode.h,
	* elflink.c, * elfnn-ia64.c, * elfnn-riscv.c, * elfxx-mips.c,
	* elfxx-x86.c, * format.c, * ihex.c, * libbfd.c, * linker.c,
	* mmo.c, * opncls.c, * pdp11.c, * peXXigen.c, * pef.c,
	* peicode.h, * simple.c, * som.c, * srec.c, * stabs.c, * syms.c,
	* targets.c, * vms-lib.c, * xcofflink.c, * xtensa-isa.c: Likewise.
This commit is contained in:
Alan Modra 2020-05-20 17:25:20 +09:30
parent c31ab5a001
commit c95949892f
79 changed files with 657 additions and 1285 deletions

View File

@ -1,3 +1,26 @@
2020-05-21 Alan Modra <amodra@gmail.com>
* aoutx.h: Replace "if (x) free (x)" with "free (x)" throughout.
* archive.c, * bfd.c, * bfdio.c, * coff-alpha.c, * coff-ppc.c,
* coff-sh.c, * coff-stgo32.c, * coffcode.h, * coffgen.c,
* cofflink.c, * cpu-arm.c, * doc/chew.c, * dwarf2.c, * ecoff.c,
* ecofflink.c, * elf-eh-frame.c, * elf-m10200.c, * elf-m10300.c,
* elf-strtab.c, * elf.c, * elf32-arc.c, * elf32-arm.c,
* elf32-avr.c, * elf32-bfin.c, * elf32-cr16.c, * elf32-crx.c,
* elf32-epiphany.c, * elf32-ft32.c, * elf32-h8300.c,
* elf32-ip2k.c, * elf32-m32c.c, * elf32-m68hc11.c,
* elf32-m68k.c, * elf32-microblaze.c, * elf32-msp430.c,
* elf32-nds32.c, * elf32-nios2.c, * elf32-ppc.c, * elf32-pru.c,
* elf32-rl78.c, * elf32-rx.c, * elf32-sh.c, * elf32-spu.c,
* elf32-v850.c, * elf32-xtensa.c, * elf64-alpha.c,
* elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mips.c
* elf64-mmix.c, * elf64-ppc.c, * elf64-sparc.c, * elfcode.h,
* elflink.c, * elfnn-ia64.c, * elfnn-riscv.c, * elfxx-mips.c,
* elfxx-x86.c, * format.c, * ihex.c, * libbfd.c, * linker.c,
* mmo.c, * opncls.c, * pdp11.c, * peXXigen.c, * pef.c,
* peicode.h, * simple.c, * som.c, * srec.c, * stabs.c, * syms.c,
* targets.c, * vms-lib.c, * xcofflink.c, * xtensa-isa.c: Likewise.
2020-05-20 Nelson Chu <nelson.chu@sifive.com> 2020-05-20 Nelson Chu <nelson.chu@sifive.com>
* elfxx-riscv.h (riscv_parse_subset_t): Add new callback function * elfxx-riscv.h (riscv_parse_subset_t): Add new callback function

View File

@ -2816,8 +2816,7 @@ NAME (aout, find_nearest_line) (bfd *abfd,
else else
funclen = strlen (bfd_asymbol_name (func)); funclen = strlen (bfd_asymbol_name (func));
if (adata (abfd).line_buf != NULL) free (adata (abfd).line_buf);
free (adata (abfd).line_buf);
if (filelen + funclen == 0) if (filelen + funclen == 0)
adata (abfd).line_buf = buf = NULL; adata (abfd).line_buf = buf = NULL;
@ -2899,7 +2898,7 @@ NAME (aout, bfd_free_cached_info) (bfd *abfd)
|| abfd->tdata.aout_data == NULL) || abfd->tdata.aout_data == NULL)
return TRUE; return TRUE;
#define BFCI_FREE(x) if (x != NULL) { free (x); x = NULL; } #define BFCI_FREE(x) do { free (x); x = NULL; } while (0)
BFCI_FREE (obj_aout_symbols (abfd)); BFCI_FREE (obj_aout_symbols (abfd));
#ifdef USE_MMAP #ifdef USE_MMAP
obj_aout_external_syms (abfd) = 0; obj_aout_external_syms (abfd) = 0;
@ -5617,26 +5616,15 @@ NAME (aout, final_link) (bfd *abfd,
} }
} }
if (aout_info.contents != NULL) free (aout_info.contents);
{ aout_info.contents = NULL;
free (aout_info.contents); free (aout_info.relocs);
aout_info.contents = NULL; aout_info.relocs = NULL;
} free (aout_info.symbol_map);
if (aout_info.relocs != NULL) aout_info.symbol_map = NULL;
{ free (aout_info.output_syms);
free (aout_info.relocs); aout_info.output_syms = NULL;
aout_info.relocs = NULL;
}
if (aout_info.symbol_map != NULL)
{
free (aout_info.symbol_map);
aout_info.symbol_map = NULL;
}
if (aout_info.output_syms != NULL)
{
free (aout_info.output_syms);
aout_info.output_syms = NULL;
}
if (includes_hash_initialized) if (includes_hash_initialized)
{ {
bfd_hash_table_free (&aout_info.includes.root); bfd_hash_table_free (&aout_info.includes.root);
@ -5679,14 +5667,10 @@ NAME (aout, final_link) (bfd *abfd,
return TRUE; return TRUE;
error_return: error_return:
if (aout_info.contents != NULL) free (aout_info.contents);
free (aout_info.contents); free (aout_info.relocs);
if (aout_info.relocs != NULL) free (aout_info.symbol_map);
free (aout_info.relocs); free (aout_info.output_syms);
if (aout_info.symbol_map != NULL)
free (aout_info.symbol_map);
if (aout_info.output_syms != NULL)
free (aout_info.output_syms);
if (includes_hash_initialized) if (includes_hash_initialized)
bfd_hash_table_free (&aout_info.includes.root); bfd_hash_table_free (&aout_info.includes.root);
return FALSE; return FALSE;

View File

@ -1468,8 +1468,7 @@ adjust_relative_path (const char * path, const char * ref_path)
if (len > pathbuf_len) if (len > pathbuf_len)
{ {
if (pathbuf != NULL) free (pathbuf);
free (pathbuf);
pathbuf_len = 0; pathbuf_len = 0;
pathbuf = (char *) bfd_malloc (len); pathbuf = (char *) bfd_malloc (len);
if (pathbuf == NULL) if (pathbuf == NULL)
@ -2326,8 +2325,7 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
{ {
if (storage > syms_max) if (storage > syms_max)
{ {
if (syms_max > 0) free (syms);
free (syms);
syms_max = storage; syms_max = storage;
syms = (asymbol **) bfd_malloc (syms_max); syms = (asymbol **) bfd_malloc (syms_max);
if (syms == NULL) if (syms == NULL)
@ -2408,20 +2406,16 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
ret = BFD_SEND (arch, write_armap, ret = BFD_SEND (arch, write_armap,
(arch, elength, map, orl_count, stridx)); (arch, elength, map, orl_count, stridx));
if (syms_max > 0) free (syms);
free (syms); free (map);
if (map != NULL)
free (map);
if (first_name != NULL) if (first_name != NULL)
bfd_release (arch, first_name); bfd_release (arch, first_name);
return ret; return ret;
error_return: error_return:
if (syms_max > 0) free (syms);
free (syms); free (map);
if (map != NULL)
free (map);
if (first_name != NULL) if (first_name != NULL)
bfd_release (arch, first_name); bfd_release (arch, first_name);

View File

@ -2487,8 +2487,7 @@ bfd_demangle (bfd *abfd, const char *name, int options)
res = cplus_demangle (name, options); res = cplus_demangle (name, options);
if (alloc != NULL) free (alloc);
free (alloc);
if (res == NULL) if (res == NULL)
{ {

View File

@ -662,8 +662,7 @@ memory_bclose (struct bfd *abfd)
{ {
struct bfd_in_memory *bim = (struct bfd_in_memory *) abfd->iostream; struct bfd_in_memory *bim = (struct bfd_in_memory *) abfd->iostream;
if (bim->buffer != NULL) free (bim->buffer);
free (bim->buffer);
free (bim); free (bim);
abfd->iostream = NULL; abfd->iostream = NULL;

View File

@ -1127,13 +1127,11 @@ alpha_ecoff_get_relocated_section_contents (bfd *abfd,
abort (); abort ();
successful_return: successful_return:
if (reloc_vector != NULL) free (reloc_vector);
free (reloc_vector);
return data; return data;
error_return: error_return:
if (reloc_vector != NULL) free (reloc_vector);
free (reloc_vector);
return NULL; return NULL;
} }
@ -2171,8 +2169,7 @@ alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos)
return nbfd; return nbfd;
error_return: error_return:
if (buf != NULL) free (buf);
free (buf);
if (nbfd != NULL) if (nbfd != NULL)
bfd_close (nbfd); bfd_close (nbfd);
return NULL; return NULL;

View File

@ -2258,41 +2258,20 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
coff_debug_merge_hash_table_free (&flaginfo.debug_merge); coff_debug_merge_hash_table_free (&flaginfo.debug_merge);
debug_merge_allocated = FALSE; debug_merge_allocated = FALSE;
if (flaginfo.internal_syms != NULL) free (flaginfo.internal_syms);
{ flaginfo.internal_syms = NULL;
free (flaginfo.internal_syms); free (flaginfo.sec_ptrs);
flaginfo.internal_syms = NULL; flaginfo.sec_ptrs = NULL;
} free (flaginfo.sym_indices);
if (flaginfo.sec_ptrs != NULL) flaginfo.sym_indices = NULL;
{ free (flaginfo.linenos);
free (flaginfo.sec_ptrs); flaginfo.linenos = NULL;
flaginfo.sec_ptrs = NULL; free (flaginfo.contents);
} flaginfo.contents = NULL;
if (flaginfo.sym_indices != NULL) free (flaginfo.external_relocs);
{ flaginfo.external_relocs = NULL;
free (flaginfo.sym_indices); free (flaginfo.internal_relocs);
flaginfo.sym_indices = NULL; flaginfo.internal_relocs = NULL;
}
if (flaginfo.linenos != NULL)
{
free (flaginfo.linenos);
flaginfo.linenos = NULL;
}
if (flaginfo.contents != NULL)
{
free (flaginfo.contents);
flaginfo.contents = NULL;
}
if (flaginfo.external_relocs != NULL)
{
free (flaginfo.external_relocs);
flaginfo.external_relocs = NULL;
}
if (flaginfo.internal_relocs != NULL)
{
free (flaginfo.internal_relocs);
flaginfo.internal_relocs = NULL;
}
/* The value of the last C_FILE symbol is supposed to be the symbol /* The value of the last C_FILE symbol is supposed to be the symbol
index of the first external symbol. Write it out again if index of the first external symbol. Write it out again if
@ -2318,11 +2297,8 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
goto error_return; goto error_return;
/* The outsyms buffer is used by _bfd_coff_write_global_sym. */ /* The outsyms buffer is used by _bfd_coff_write_global_sym. */
if (flaginfo.outsyms != NULL) free (flaginfo.outsyms);
{ flaginfo.outsyms = NULL;
free (flaginfo.outsyms);
flaginfo.outsyms = NULL;
}
if (bfd_link_relocatable (info)) if (bfd_link_relocatable (info))
{ {
@ -2375,10 +2351,8 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
for (i = 0; i < abfd->section_count; i++) for (i = 0; i < abfd->section_count; i++)
{ {
if (flaginfo.section_info[i].relocs != NULL) free (flaginfo.section_info[i].relocs);
free (flaginfo.section_info[i].relocs); free (flaginfo.section_info[i].rel_hashes);
if (flaginfo.section_info[i].rel_hashes != NULL)
free (flaginfo.section_info[i].rel_hashes);
} }
free (flaginfo.section_info); free (flaginfo.section_info);
flaginfo.section_info = NULL; flaginfo.section_info = NULL;
@ -2435,31 +2409,20 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
for (i = 0; i < abfd->section_count; i++) for (i = 0; i < abfd->section_count; i++)
{ {
if (flaginfo.section_info[i].relocs != NULL) free (flaginfo.section_info[i].relocs);
free (flaginfo.section_info[i].relocs); free (flaginfo.section_info[i].rel_hashes);
if (flaginfo.section_info[i].rel_hashes != NULL)
free (flaginfo.section_info[i].rel_hashes);
} }
free (flaginfo.section_info); free (flaginfo.section_info);
} }
if (flaginfo.internal_syms != NULL) free (flaginfo.internal_syms);
free (flaginfo.internal_syms); free (flaginfo.sec_ptrs);
if (flaginfo.sec_ptrs != NULL) free (flaginfo.sym_indices);
free (flaginfo.sec_ptrs); free (flaginfo.outsyms);
if (flaginfo.sym_indices != NULL) free (flaginfo.linenos);
free (flaginfo.sym_indices); free (flaginfo.contents);
if (flaginfo.outsyms != NULL) free (flaginfo.external_relocs);
free (flaginfo.outsyms); free (flaginfo.internal_relocs);
if (flaginfo.linenos != NULL) free (external_relocs);
free (flaginfo.linenos);
if (flaginfo.contents != NULL)
free (flaginfo.contents);
if (flaginfo.external_relocs != NULL)
free (flaginfo.external_relocs);
if (flaginfo.internal_relocs != NULL)
free (flaginfo.internal_relocs);
if (external_relocs != NULL)
free (external_relocs);
return FALSE; return FALSE;
} }
#endif #endif

View File

@ -1056,10 +1056,9 @@ sh_relax_section (bfd *abfd,
return TRUE; return TRUE;
error_return: error_return:
if (internal_relocs != NULL if (internal_relocs != coff_section_data (abfd, sec)->relocs)
&& internal_relocs != coff_section_data (abfd, sec)->relocs)
free (internal_relocs); free (internal_relocs);
if (contents != NULL && contents != coff_section_data (abfd, sec)->contents) if (contents != coff_section_data (abfd, sec)->contents)
free (contents); free (contents);
return FALSE; return FALSE;
} }
@ -2723,8 +2722,7 @@ sh_align_loads (bfd *abfd,
return TRUE; return TRUE;
error_return: error_return:
if (labels != NULL) free (labels);
free (labels);
return FALSE; return FALSE;
} }
@ -2995,12 +2993,9 @@ sh_coff_get_relocated_section_contents (bfd *output_bfd,
return data; return data;
error_return: error_return:
if (internal_relocs != NULL) free (internal_relocs);
free (internal_relocs); free (internal_syms);
if (internal_syms != NULL) free (sections);
free (internal_syms);
if (sections != NULL)
free (sections);
return NULL; return NULL;
} }

View File

@ -249,8 +249,7 @@ go32exe_cleanup (bfd *abfd)
{ {
abfd->origin = 0; abfd->origin = 0;
if (go32exe_temp_stub != NULL) free (go32exe_temp_stub);
free (go32exe_temp_stub);
go32exe_temp_stub = NULL; go32exe_temp_stub = NULL;
go32exe_temp_stub_size = 0; go32exe_temp_stub_size = 0;
} }

View File

@ -2666,8 +2666,7 @@ coff_write_relocs (bfd * abfd, int first_undef)
} }
#ifdef TARG_AUX #ifdef TARG_AUX
if (p != NULL) free (p);
free (p);
#endif #endif
} }

View File

@ -544,11 +544,8 @@ _bfd_coff_read_internal_relocs (bfd *abfd,
for (; erel < erel_end; erel += relsz, irel++) for (; erel < erel_end; erel += relsz, irel++)
bfd_coff_swap_reloc_in (abfd, (void *) erel, (void *) irel); bfd_coff_swap_reloc_in (abfd, (void *) erel, (void *) irel);
if (free_external != NULL) free (free_external);
{ free_external = NULL;
free (free_external);
free_external = NULL;
}
if (cache && free_internal != NULL) if (cache && free_internal != NULL)
{ {
@ -566,10 +563,8 @@ _bfd_coff_read_internal_relocs (bfd *abfd,
return internal_relocs; return internal_relocs;
error_return: error_return:
if (free_external != NULL) free (free_external);
free (free_external); free (free_internal);
if (free_internal != NULL)
free (free_internal);
return NULL; return NULL;
} }

View File

@ -993,41 +993,20 @@ _bfd_coff_final_link (bfd *abfd,
coff_debug_merge_hash_table_free (&flaginfo.debug_merge); coff_debug_merge_hash_table_free (&flaginfo.debug_merge);
debug_merge_allocated = FALSE; debug_merge_allocated = FALSE;
if (flaginfo.internal_syms != NULL) free (flaginfo.internal_syms);
{ flaginfo.internal_syms = NULL;
free (flaginfo.internal_syms); free (flaginfo.sec_ptrs);
flaginfo.internal_syms = NULL; flaginfo.sec_ptrs = NULL;
} free (flaginfo.sym_indices);
if (flaginfo.sec_ptrs != NULL) flaginfo.sym_indices = NULL;
{ free (flaginfo.linenos);
free (flaginfo.sec_ptrs); flaginfo.linenos = NULL;
flaginfo.sec_ptrs = NULL; free (flaginfo.contents);
} flaginfo.contents = NULL;
if (flaginfo.sym_indices != NULL) free (flaginfo.external_relocs);
{ flaginfo.external_relocs = NULL;
free (flaginfo.sym_indices); free (flaginfo.internal_relocs);
flaginfo.sym_indices = NULL; flaginfo.internal_relocs = NULL;
}
if (flaginfo.linenos != NULL)
{
free (flaginfo.linenos);
flaginfo.linenos = NULL;
}
if (flaginfo.contents != NULL)
{
free (flaginfo.contents);
flaginfo.contents = NULL;
}
if (flaginfo.external_relocs != NULL)
{
free (flaginfo.external_relocs);
flaginfo.external_relocs = NULL;
}
if (flaginfo.internal_relocs != NULL)
{
free (flaginfo.internal_relocs);
flaginfo.internal_relocs = NULL;
}
/* The value of the last C_FILE symbol is supposed to be the symbol /* The value of the last C_FILE symbol is supposed to be the symbol
index of the first external symbol. Write it out again if index of the first external symbol. Write it out again if
@ -1066,11 +1045,8 @@ _bfd_coff_final_link (bfd *abfd,
goto error_return; goto error_return;
/* The outsyms buffer is used by _bfd_coff_write_global_sym. */ /* The outsyms buffer is used by _bfd_coff_write_global_sym. */
if (flaginfo.outsyms != NULL) free (flaginfo.outsyms);
{ flaginfo.outsyms = NULL;
free (flaginfo.outsyms);
flaginfo.outsyms = NULL;
}
if (bfd_link_relocatable (info) && max_output_reloc_count > 0) if (bfd_link_relocatable (info) && max_output_reloc_count > 0)
{ {
@ -1141,10 +1117,8 @@ _bfd_coff_final_link (bfd *abfd,
for (i = 0; i < abfd->section_count; i++) for (i = 0; i < abfd->section_count; i++)
{ {
if (flaginfo.section_info[i].relocs != NULL) free (flaginfo.section_info[i].relocs);
free (flaginfo.section_info[i].relocs); free (flaginfo.section_info[i].rel_hashes);
if (flaginfo.section_info[i].rel_hashes != NULL)
free (flaginfo.section_info[i].rel_hashes);
} }
free (flaginfo.section_info); free (flaginfo.section_info);
flaginfo.section_info = NULL; flaginfo.section_info = NULL;
@ -1203,31 +1177,20 @@ _bfd_coff_final_link (bfd *abfd,
for (i = 0; i < abfd->section_count; i++) for (i = 0; i < abfd->section_count; i++)
{ {
if (flaginfo.section_info[i].relocs != NULL) free (flaginfo.section_info[i].relocs);
free (flaginfo.section_info[i].relocs); free (flaginfo.section_info[i].rel_hashes);
if (flaginfo.section_info[i].rel_hashes != NULL)
free (flaginfo.section_info[i].rel_hashes);
} }
free (flaginfo.section_info); free (flaginfo.section_info);
} }
if (flaginfo.internal_syms != NULL) free (flaginfo.internal_syms);
free (flaginfo.internal_syms); free (flaginfo.sec_ptrs);
if (flaginfo.sec_ptrs != NULL) free (flaginfo.sym_indices);
free (flaginfo.sec_ptrs); free (flaginfo.outsyms);
if (flaginfo.sym_indices != NULL) free (flaginfo.linenos);
free (flaginfo.sym_indices); free (flaginfo.contents);
if (flaginfo.outsyms != NULL) free (flaginfo.external_relocs);
free (flaginfo.outsyms); free (flaginfo.internal_relocs);
if (flaginfo.linenos != NULL) free (external_relocs);
free (flaginfo.linenos);
if (flaginfo.contents != NULL)
free (flaginfo.contents);
if (flaginfo.external_relocs != NULL)
free (flaginfo.external_relocs);
if (flaginfo.internal_relocs != NULL)
free (flaginfo.internal_relocs);
if (external_relocs != NULL)
free (external_relocs);
return FALSE; return FALSE;
} }
@ -1286,8 +1249,7 @@ process_embedded_commands (bfd *output_bfd,
if (!bfd_malloc_and_get_section (abfd, sec, &copy)) if (!bfd_malloc_and_get_section (abfd, sec, &copy))
{ {
if (copy != NULL) free (copy);
free (copy);
return 0; return 0;
} }
e = (char *) copy + sec->size; e = (char *) copy + sec->size;

View File

@ -458,8 +458,7 @@ bfd_arm_update_notes (bfd *abfd, const char *note_section)
return TRUE; return TRUE;
FAIL: FAIL:
if (buffer != NULL) free (buffer);
free (buffer);
return FALSE; return FALSE;
} }
@ -528,8 +527,7 @@ bfd_arm_get_mach_from_notes (bfd *abfd, const char *note_section)
} }
FAIL: FAIL:
if (buffer != NULL) free (buffer);
free (buffer);
return bfd_mach_arm_unknown; return bfd_mach_arm_unknown;
} }

View File

@ -170,8 +170,7 @@ static void
delete_string (buffer) delete_string (buffer)
string_type *buffer; string_type *buffer;
{ {
if (buffer->ptr) free (buffer->ptr);
free (buffer->ptr);
buffer->ptr = NULL; buffer->ptr = NULL;
} }
@ -1258,8 +1257,7 @@ free_words (void)
{ {
dict_type *next; dict_type *next;
if (ptr->word) free (ptr->word);
free (ptr->word);
if (ptr->code) if (ptr->code)
{ {
int i; int i;
@ -1443,8 +1441,7 @@ compile (string)
fprintf (stderr, "syntax error at %s\n", string - 1); fprintf (stderr, "syntax error at %s\n", string - 1);
} }
} }
if (word) free (word);
free (word);
} }
static void static void

View File

@ -2420,8 +2420,7 @@ decode_line_info (struct comp_unit *unit)
(_("DWARF error: mangled line number section")); (_("DWARF error: mangled line number section"));
bfd_set_error (bfd_error_bad_value); bfd_set_error (bfd_error_bad_value);
line_fail: line_fail:
if (filename != NULL) free (filename);
free (filename);
goto fail; goto fail;
} }
break; break;
@ -2466,8 +2465,7 @@ decode_line_info (struct comp_unit *unit)
filenum = _bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read, filenum = _bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read,
FALSE, line_end); FALSE, line_end);
line_ptr += bytes_read; line_ptr += bytes_read;
if (filename) free (filename);
free (filename);
filename = concat_filename (table, filenum); filename = concat_filename (table, filenum);
break; break;
} }
@ -2513,8 +2511,7 @@ decode_line_info (struct comp_unit *unit)
} }
} }
if (filename) free (filename);
free (filename);
} }
if (unit->line_offset == 0) if (unit->line_offset == 0)
@ -2529,10 +2526,8 @@ decode_line_info (struct comp_unit *unit)
table->sequences = table->sequences->prev_sequence; table->sequences = table->sequences->prev_sequence;
free (seq); free (seq);
} }
if (table->files != NULL) free (table->files);
free (table->files); free (table->dirs);
if (table->dirs != NULL)
free (table->dirs);
return NULL; return NULL;
} }
@ -5146,34 +5141,22 @@ _bfd_dwarf2_cleanup_debug_info (bfd *abfd, void **pinfo)
free (each->line_table->dirs); free (each->line_table->dirs);
} }
if (each->lookup_funcinfo_table) free (each->lookup_funcinfo_table);
{ each->lookup_funcinfo_table = NULL;
free (each->lookup_funcinfo_table);
each->lookup_funcinfo_table = NULL;
}
while (function_table) while (function_table)
{ {
if (function_table->file) free (function_table->file);
{ function_table->file = NULL;
free (function_table->file); free (function_table->caller_file);
function_table->file = NULL; function_table->caller_file = NULL;
}
if (function_table->caller_file)
{
free (function_table->caller_file);
function_table->caller_file = NULL;
}
function_table = function_table->prev_func; function_table = function_table->prev_func;
} }
while (variable_table) while (variable_table)
{ {
if (variable_table->file) free (variable_table->file);
{ variable_table->file = NULL;
free (variable_table->file);
variable_table->file = NULL;
}
variable_table = variable_table->prev_var; variable_table = variable_table->prev_var;
} }
} }

View File

@ -488,12 +488,10 @@ ecoff_slurp_symbolic_header (bfd *abfd)
/* Now we can get the correct number of symbols. */ /* Now we can get the correct number of symbols. */
abfd->symcount = internal_symhdr->isymMax + internal_symhdr->iextMax; abfd->symcount = internal_symhdr->isymMax + internal_symhdr->iextMax;
if (raw != NULL) free (raw);
free (raw);
return TRUE; return TRUE;
error_return: error_return:
if (raw != NULL) free (raw);
free (raw);
return FALSE; return FALSE;
} }
@ -2797,14 +2795,12 @@ _bfd_ecoff_write_object_contents (bfd *abfd)
if (reloc_buff != NULL) if (reloc_buff != NULL)
bfd_release (abfd, reloc_buff); bfd_release (abfd, reloc_buff);
if (buff != NULL) free (buff);
free (buff);
return TRUE; return TRUE;
error_return: error_return:
if (reloc_buff != NULL) if (reloc_buff != NULL)
bfd_release (abfd, reloc_buff); bfd_release (abfd, reloc_buff);
if (buff != NULL) free (buff);
free (buff);
return FALSE; return FALSE;
} }
@ -3528,17 +3524,13 @@ ecoff_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
result = ecoff_link_add_externals (abfd, info, external_ext, ssext); result = ecoff_link_add_externals (abfd, info, external_ext, ssext);
if (ssext != NULL) free (ssext);
free (ssext); free (external_ext);
if (external_ext != NULL)
free (external_ext);
return result; return result;
error_return: error_return:
if (ssext != NULL) free (ssext);
free (ssext); free (external_ext);
if (external_ext != NULL)
free (external_ext);
return FALSE; return FALSE;
} }
@ -3820,24 +3812,15 @@ ecoff_final_link_debug_accumulate (bfd *output_bfd,
return_something: return_something:
if (ecoff_data (input_bfd)->raw_syments == NULL) if (ecoff_data (input_bfd)->raw_syments == NULL)
{ {
if (debug->line != NULL) free (debug->line);
free (debug->line); free (debug->external_dnr);
if (debug->external_dnr != NULL) free (debug->external_pdr);
free (debug->external_dnr); free (debug->external_sym);
if (debug->external_pdr != NULL) free (debug->external_opt);
free (debug->external_pdr); free (debug->external_aux);
if (debug->external_sym != NULL) free (debug->ss);
free (debug->external_sym); free (debug->external_fdr);
if (debug->external_opt != NULL) free (debug->external_rfd);
free (debug->external_opt);
if (debug->external_aux != NULL)
free (debug->external_aux);
if (debug->ss != NULL)
free (debug->ss);
if (debug->external_fdr != NULL)
free (debug->external_fdr);
if (debug->external_rfd != NULL)
free (debug->external_rfd);
/* Make sure we don't accidentally follow one of these pointers /* Make sure we don't accidentally follow one of these pointers
into freed memory. */ into freed memory. */
@ -3926,17 +3909,13 @@ ecoff_indirect_link_order (bfd *output_bfd,
output_section->reloc_count += input_section->reloc_count; output_section->reloc_count += input_section->reloc_count;
} }
if (contents != NULL) free (contents);
free (contents); free (external_relocs);
if (external_relocs != NULL)
free (external_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (contents != NULL) free (contents);
free (contents); free (external_relocs);
if (external_relocs != NULL)
free (external_relocs);
return FALSE; return FALSE;
} }

View File

@ -1464,12 +1464,10 @@ ecoff_write_symhdr (bfd *abfd,
!= swap->external_hdr_size) != swap->external_hdr_size)
goto error_return; goto error_return;
if (buff != NULL) free (buff);
free (buff);
return TRUE; return TRUE;
error_return: error_return:
if (buff != NULL) free (buff);
free (buff);
return FALSE; return FALSE;
} }
@ -1685,13 +1683,11 @@ bfd_ecoff_write_accumulated_debug (void * handle,
if (bfd_bwrite (debug->external_ext, amt, abfd) != amt) if (bfd_bwrite (debug->external_ext, amt, abfd) != amt)
goto error_return; goto error_return;
if (space != NULL) free (space);
free (space);
return TRUE; return TRUE;
error_return: error_return:
if (space != NULL) free (space);
free (space);
return FALSE; return FALSE;
} }
@ -2320,12 +2316,11 @@ lookup_line (bfd *abfd,
if (len != 0) if (len != 0)
{ {
if (line_info->find_buffer != NULL) free (line_info->find_buffer);
free (line_info->find_buffer);
buffer = (char *) bfd_malloc ((bfd_size_type) len); buffer = (char *) bfd_malloc ((bfd_size_type) len);
line_info->find_buffer = buffer;
if (buffer == NULL) if (buffer == NULL)
return FALSE; return FALSE;
line_info->find_buffer = buffer;
} }
if (function_name != NULL) if (function_name != NULL)

View File

@ -1049,13 +1049,10 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
(_("error in %pB(%pA); no .eh_frame_hdr table will be created"), (_("error in %pB(%pA); no .eh_frame_hdr table will be created"),
abfd, sec); abfd, sec);
hdr_info->u.dwarf.table = FALSE; hdr_info->u.dwarf.table = FALSE;
if (sec_info) free (sec_info);
free (sec_info);
success: success:
if (ehbuf) free (ehbuf);
free (ehbuf); free (local_cies);
if (local_cies)
free (local_cies);
#undef REQUIRE #undef REQUIRE
} }
@ -1558,11 +1555,8 @@ _bfd_elf_discard_section_eh_frame
} }
} }
if (sec_info->cies) free (sec_info->cies);
{ sec_info->cies = NULL;
free (sec_info->cies);
sec_info->cies = NULL;
}
/* It may be that some .eh_frame input section has greater alignment /* It may be that some .eh_frame input section has greater alignment
than other .eh_frame sections. In that case we run the risk of than other .eh_frame sections. In that case we run the risk of
@ -2511,8 +2505,7 @@ write_dwarf_eh_frame_hdr (bfd *abfd, struct bfd_link_info *info)
retval = FALSE; retval = FALSE;
free (contents); free (contents);
if (hdr_info->u.dwarf.array != NULL) free (hdr_info->u.dwarf.array);
free (hdr_info->u.dwarf.array);
return retval; return retval;
} }

View File

@ -1207,21 +1207,17 @@ mn10200_elf_relax_section (bfd *abfd,
} }
} }
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL if (symtab_hdr->contents != (unsigned char *) isymbuf)
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
@ -1355,10 +1351,8 @@ mn10200_elf_get_relocated_section_contents (bfd *output_bfd,
isymbuf, sections)) isymbuf, sections))
goto error_return; goto error_return;
if (sections != NULL) free (sections);
free (sections); if (symtab_hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (elf_section_data (input_section)->relocs != internal_relocs) if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
@ -1367,13 +1361,10 @@ mn10200_elf_get_relocated_section_contents (bfd *output_bfd,
return data; return data;
error_return: error_return:
if (sections != NULL) free (sections);
free (sections); if (symtab_hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (internal_relocs != NULL if (elf_section_data (input_section)->relocs != internal_relocs)
&& elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return NULL; return NULL;
} }

View File

@ -1372,7 +1372,7 @@ mn10300_elf_check_relocs (bfd *abfd,
result = TRUE; result = TRUE;
fail: fail:
if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf) if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
return result; return result;
@ -2912,8 +2912,7 @@ mn10300_elf_relax_section (bfd *abfd,
} }
/* Cache or free any memory we allocated for the relocs. */ /* Cache or free any memory we allocated for the relocs. */
if (internal_relocs != NULL if (elf_section_data (section)->relocs != internal_relocs)
&& elf_section_data (section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
internal_relocs = NULL; internal_relocs = NULL;
@ -3222,8 +3221,7 @@ mn10300_elf_relax_section (bfd *abfd,
} }
/* Cache or free any memory we allocated for the relocs. */ /* Cache or free any memory we allocated for the relocs. */
if (internal_relocs != NULL if (elf_section_data (section)->relocs != internal_relocs)
&& elf_section_data (section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
internal_relocs = NULL; internal_relocs = NULL;
@ -4391,21 +4389,17 @@ mn10300_elf_relax_section (bfd *abfd,
} }
} }
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL if (symtab_hdr->contents != (unsigned char *) isymbuf)
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (section)->this_hdr.contents != contents)
&& elf_section_data (section)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (section)->relocs != internal_relocs)
&& elf_section_data (section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
@ -4494,9 +4488,8 @@ mn10300_elf_get_relocated_section_contents (bfd *output_bfd,
isymbuf, sections)) isymbuf, sections))
goto error_return; goto error_return;
if (sections != NULL) free (sections);
free (sections); if (symtab_hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (internal_relocs != elf_section_data (input_section)->relocs) if (internal_relocs != elf_section_data (input_section)->relocs)
free (internal_relocs); free (internal_relocs);
@ -4505,12 +4498,10 @@ mn10300_elf_get_relocated_section_contents (bfd *output_bfd,
return data; return data;
error_return: error_return:
if (sections != NULL) free (sections);
free (sections); if (symtab_hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (internal_relocs != NULL if (internal_relocs != elf_section_data (input_section)->relocs)
&& internal_relocs != elf_section_data (input_section)->relocs)
free (internal_relocs); free (internal_relocs);
return NULL; return NULL;
} }

View File

@ -443,8 +443,7 @@ _bfd_elf_strtab_finalize (struct elf_strtab_hash *tab)
} }
alloc_failure: alloc_failure:
if (array) free (array);
free (array);
/* Assign positions to the strings we want to keep. */ /* Assign positions to the strings we want to keep. */
sec_size = 1; sec_size = 1;

View File

@ -513,17 +513,14 @@ bfd_elf_get_elf_syms (bfd *ibfd,
_bfd_error_handler (_("%pB symbol number %lu references" _bfd_error_handler (_("%pB symbol number %lu references"
" nonexistent SHT_SYMTAB_SHNDX section"), " nonexistent SHT_SYMTAB_SHNDX section"),
ibfd, (unsigned long) symoffset); ibfd, (unsigned long) symoffset);
if (alloc_intsym != NULL) free (alloc_intsym);
free (alloc_intsym);
intsym_buf = NULL; intsym_buf = NULL;
goto out; goto out;
} }
out: out:
if (alloc_ext != NULL) free (alloc_ext);
free (alloc_ext); free (alloc_extshndx);
if (alloc_extshndx != NULL)
free (alloc_extshndx);
return intsym_buf; return intsym_buf;
} }
@ -1878,8 +1875,7 @@ _bfd_elf_print_private_bfd_data (bfd *abfd, void *farg)
return TRUE; return TRUE;
error_return: error_return:
if (dynbuf != NULL) free (dynbuf);
free (dynbuf);
return FALSE; return FALSE;
} }
@ -5252,8 +5248,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
return TRUE; return TRUE;
error_return: error_return:
if (sections != NULL) free (sections);
free (sections);
return FALSE; return FALSE;
} }
@ -9037,8 +9032,7 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bfd_boolean default_imported_symver)
return TRUE; return TRUE;
error_return: error_return:
if (contents != NULL) free (contents);
free (contents);
return FALSE; return FALSE;
} }

View File

@ -3128,21 +3128,17 @@ arc_elf_relax_section (bfd *abfd, asection *sec,
elf_section_data (sec)->this_hdr.contents = contents; elf_section_data (sec)->this_hdr.contents = contents;
} }
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL if (symtab_hdr->contents != (unsigned char *) isymbuf)
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;

View File

@ -6617,9 +6617,7 @@ elf32_arm_size_stubs (bfd *output_bfd,
free (internal_relocs); free (internal_relocs);
/* Fall through. */ /* Fall through. */
error_ret_free_local: error_ret_free_local:
if (local_syms != NULL if (symtab_hdr->contents != (unsigned char *) local_syms)
&& (symtab_hdr->contents
!= (unsigned char *) local_syms))
free (local_syms); free (local_syms);
return FALSE; return FALSE;
} }
@ -7986,13 +7984,11 @@ bfd_elf32_arm_process_before_allocation (bfd *abfd,
} }
} }
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
contents = NULL; contents = NULL;
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
internal_relocs = NULL; internal_relocs = NULL;
} }
@ -8000,11 +7996,9 @@ bfd_elf32_arm_process_before_allocation (bfd *abfd,
return TRUE; return TRUE;
error_return: error_return:
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
@ -8607,8 +8601,7 @@ bfd_elf32_arm_vfp11_erratum_scan (bfd *abfd, struct bfd_link_info *link_info)
} }
} }
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
contents = NULL; contents = NULL;
} }
@ -8616,8 +8609,7 @@ bfd_elf32_arm_vfp11_erratum_scan (bfd *abfd, struct bfd_link_info *link_info)
return TRUE; return TRUE;
error_return: error_return:
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
return FALSE; return FALSE;
@ -9044,8 +9036,7 @@ bfd_elf32_arm_stm32l4xx_erratum_scan (bfd *abfd,
} }
} }
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
contents = NULL; contents = NULL;
} }
@ -9053,8 +9044,7 @@ bfd_elf32_arm_stm32l4xx_erratum_scan (bfd *abfd,
return TRUE; return TRUE;
error_return: error_return:
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
return FALSE; return FALSE;

View File

@ -858,10 +858,8 @@ elf32_avr_link_hash_table_free (bfd *obfd)
= (struct elf32_avr_link_hash_table *) obfd->link.hash; = (struct elf32_avr_link_hash_table *) obfd->link.hash;
/* Free the address mapping table. */ /* Free the address mapping table. */
if (htab->amt_stub_offsets != NULL) free (htab->amt_stub_offsets);
free (htab->amt_stub_offsets); free (htab->amt_destination_addr);
if (htab->amt_destination_addr != NULL)
free (htab->amt_destination_addr);
bfd_hash_table_free (&htab->bstab); bfd_hash_table_free (&htab->bstab);
_bfd_elf_link_hash_table_free (obfd); _bfd_elf_link_hash_table_free (obfd);
@ -3166,21 +3164,17 @@ elf32_avr_relax_section (bfd *abfd,
} }
} }
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL if (symtab_hdr->contents != (unsigned char *) isymbuf)
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
@ -3273,10 +3267,8 @@ elf32_avr_get_relocated_section_contents (bfd *output_bfd,
isymbuf, sections)) isymbuf, sections))
goto error_return; goto error_return;
if (sections != NULL) free (sections);
free (sections); if (symtab_hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (elf_section_data (input_section)->relocs != internal_relocs) if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
@ -3285,13 +3277,10 @@ elf32_avr_get_relocated_section_contents (bfd *output_bfd,
return data; return data;
error_return: error_return:
if (sections != NULL) free (sections);
free (sections); if (symtab_hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (internal_relocs != NULL if (elf_section_data (input_section)->relocs != internal_relocs)
&& elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return NULL; return NULL;
} }

View File

@ -5395,18 +5395,16 @@ bfd_bfin_elf32_create_embedded_relocs (bfd *abfd,
strncpy ((char *) p + 4, targetsec->output_section->name, 8); strncpy ((char *) p + 4, targetsec->output_section->name, 8);
} }
if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf) if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (internal_relocs != NULL if (elf_section_data (datasec)->relocs != internal_relocs)
&& elf_section_data (datasec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf) if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (internal_relocs != NULL if (elf_section_data (datasec)->relocs != internal_relocs)
&& elf_section_data (datasec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
} }

View File

@ -824,10 +824,9 @@ cr16_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
} }
} }
result = TRUE; result = TRUE;
fail: fail:
if (isymbuf != NULL) free (isymbuf);
free (isymbuf);
return result; return result;
} }
@ -1572,10 +1571,8 @@ elf32_cr16_get_relocated_section_contents (bfd *output_bfd,
isymbuf, sections)) isymbuf, sections))
goto error_return; goto error_return;
if (sections != NULL) free (sections);
free (sections); if (symtab_hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (elf_section_data (input_section)->relocs != internal_relocs) if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
@ -1584,13 +1581,10 @@ elf32_cr16_get_relocated_section_contents (bfd *output_bfd,
return data; return data;
error_return: error_return:
if (sections != NULL) free (sections);
free (sections); if (symtab_hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (internal_relocs != NULL if (elf_section_data (input_section)->relocs != internal_relocs)
&& elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return NULL; return NULL;
} }
@ -2174,21 +2168,17 @@ elf32_cr16_relax_section (bfd *abfd, asection *sec,
} }
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL if (symtab_hdr->contents != (unsigned char *) isymbuf)
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
@ -2847,18 +2837,16 @@ bfd_cr16_elf32_create_embedded_relocs (bfd *abfd,
strncpy ((char *) p + 4, targetsec->output_section->name, 4); strncpy ((char *) p + 4, targetsec->output_section->name, 4);
} }
if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf) if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (internal_relocs != NULL if (elf_section_data (datasec)->relocs != internal_relocs)
&& elf_section_data (datasec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf) if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (internal_relocs != NULL if (elf_section_data (datasec)->relocs != internal_relocs)
&& elf_section_data (datasec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
} }

View File

@ -805,10 +805,8 @@ elf32_crx_get_relocated_section_contents (bfd *output_bfd,
isymbuf, sections)) isymbuf, sections))
goto error_return; goto error_return;
if (sections != NULL) free (sections);
free (sections); if (symtab_hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (elf_section_data (input_section)->relocs != internal_relocs) if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
@ -817,13 +815,10 @@ elf32_crx_get_relocated_section_contents (bfd *output_bfd,
return data; return data;
error_return: error_return:
if (sections != NULL) free (sections);
free (sections); if (symtab_hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (internal_relocs != NULL if (elf_section_data (input_section)->relocs != internal_relocs)
&& elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return NULL; return NULL;
} }
@ -1289,21 +1284,17 @@ elf32_crx_relax_section (bfd *abfd, asection *sec,
} }
} }
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL if (symtab_hdr->contents != (unsigned char *) isymbuf)
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;

View File

@ -341,21 +341,17 @@ epiphany_elf_relax_section (bfd *abfd, asection *sec,
} }
} }
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL if (symtab_hdr->contents != (unsigned char *) isymbuf)
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
} }

View File

@ -1230,15 +1230,13 @@ ft32_elf_relax_section
} }
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (free_relocs != NULL) free (free_relocs);
free (free_relocs);
return TRUE; return TRUE;
} }

View File

@ -1465,21 +1465,17 @@ elf32_h8_relax_section (bfd *abfd, asection *sec,
} }
} }
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL if (symtab_hdr->contents != (unsigned char *) isymbuf)
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
} }
@ -1682,10 +1678,8 @@ elf32_h8_get_relocated_section_contents (bfd *output_bfd,
isymbuf, sections)) isymbuf, sections))
goto error_return; goto error_return;
if (sections != NULL) free (sections);
free (sections); if (symtab_hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (elf_section_data (input_section)->relocs != internal_relocs) if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
@ -1694,13 +1688,10 @@ elf32_h8_get_relocated_section_contents (bfd *output_bfd,
return data; return data;
error_return: error_return:
if (sections != NULL) free (sections);
free (sections); if (symtab_hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (internal_relocs != NULL if (elf_section_data (input_section)->relocs != internal_relocs)
&& elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return NULL; return NULL;
} }

View File

@ -638,8 +638,7 @@ adjust_all_relocations (bfd *abfd,
{ {
if (!bfd_malloc_and_get_section (abfd, stab, &stabcontents)) if (!bfd_malloc_and_get_section (abfd, stab, &stabcontents))
{ {
if (stabcontents != NULL) free (stabcontents);
free (stabcontents);
return; return;
} }
@ -1210,21 +1209,17 @@ ip2k_elf_relax_section (bfd *abfd,
} }
} }
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL if (symtab_hdr->contents != (unsigned char *) isymbuf)
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
} }

View File

@ -1901,11 +1901,8 @@ m32c_elf_relax_section
} /* next relocation */ } /* next relocation */
if (free_relocs != NULL) free (free_relocs);
{ free_relocs = NULL;
free (free_relocs);
free_relocs = NULL;
}
if (free_contents != NULL) if (free_contents != NULL)
{ {
@ -1931,7 +1928,7 @@ m32c_elf_relax_section
/* Cache the symbols for elf_link_input_bfd. */ /* Cache the symbols for elf_link_input_bfd. */
else else
{ {
symtab_hdr->contents = NULL /* (unsigned char *) intsyms*/; symtab_hdr->contents = NULL /* (unsigned char *) intsyms*/;
} }
free_intsyms = NULL; free_intsyms = NULL;
@ -1940,17 +1937,14 @@ m32c_elf_relax_section
return TRUE; return TRUE;
error_return: error_return:
if (free_relocs != NULL) free (free_relocs);
free (free_relocs); free (free_contents);
if (free_contents != NULL)
free (free_contents);
if (shndx_buf != NULL) if (shndx_buf != NULL)
{ {
shndx_hdr->contents = NULL; shndx_hdr->contents = NULL;
free (shndx_buf); free (shndx_buf);
} }
if (free_intsyms != NULL) free (free_intsyms);
free (free_intsyms);
return FALSE; return FALSE;
} }

View File

@ -1082,11 +1082,8 @@ m68hc11_elf_relax_section (bfd *abfd, asection *sec,
prev_insn_group = 0; prev_insn_group = 0;
} }
if (free_relocs != NULL) free (free_relocs);
{ free_relocs = NULL;
free (free_relocs);
free_relocs = NULL;
}
if (free_contents != NULL) if (free_contents != NULL)
{ {
@ -1115,12 +1112,9 @@ m68hc11_elf_relax_section (bfd *abfd, asection *sec,
return TRUE; return TRUE;
error_return: error_return:
if (free_relocs != NULL) free (free_relocs);
free (free_relocs); free (free_contents);
if (free_contents != NULL) free (free_extsyms);
free (free_contents);
if (free_extsyms != NULL)
free (free_extsyms);
return FALSE; return FALSE;
} }

View File

@ -4448,18 +4448,16 @@ bfd_m68k_elf32_create_embedded_relocs (bfd *abfd, struct bfd_link_info *info,
strncpy ((char *) p + 4, targetsec->output_section->name, 8); strncpy ((char *) p + 4, targetsec->output_section->name, 8);
} }
if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf) if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (internal_relocs != NULL if (elf_section_data (datasec)->relocs != internal_relocs)
&& elf_section_data (datasec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf) if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (internal_relocs != NULL if (elf_section_data (datasec)->relocs != internal_relocs)
&& elf_section_data (datasec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
} }

View File

@ -2234,11 +2234,8 @@ microblaze_elf_relax_section (bfd *abfd,
symtab_hdr->contents = (bfd_byte *) isymbuf; symtab_hdr->contents = (bfd_byte *) isymbuf;
} }
if (free_relocs != NULL) free (free_relocs);
{ free_relocs = NULL;
free (free_relocs);
free_relocs = NULL;
}
if (free_contents != NULL) if (free_contents != NULL)
{ {
@ -2261,16 +2258,11 @@ microblaze_elf_relax_section (bfd *abfd,
return TRUE; return TRUE;
error_return: error_return:
if (free_relocs != NULL) free (free_relocs);
free (free_relocs); free (free_contents);
if (free_contents != NULL) free (sec->relax);
free (free_contents); sec->relax = NULL;
if (sec->relax != NULL) sec->relax_count = 0;
{
free (sec->relax);
sec->relax = NULL;
sec->relax_count = 0;
}
return FALSE; return FALSE;
} }

View File

@ -2487,20 +2487,17 @@ msp430_elf_relax_section (bfd * abfd, asection * sec,
} }
} }
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf) if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;

View File

@ -12572,15 +12572,13 @@ nds32_elf_relax_section (bfd *abfd, asection *sec,
} }
finish: finish:
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (isymbuf != NULL && symtab_hdr->contents != (bfd_byte *) isymbuf) if (symtab_hdr->contents != (bfd_byte *) isymbuf)
free (isymbuf); free (isymbuf);
return result; return result;
@ -13473,7 +13471,7 @@ elf32_nds32_check_relax_group (bfd *abfd, asection *asec)
} }
while (FALSE); while (FALSE);
if ((relocs != NULL) && (elf_section_data (asec)->relocs != relocs)) if (elf_section_data (asec)->relocs != relocs)
free (relocs); free (relocs);
if ((min_id != relax_group_ptr->min_id) if ((min_id != relax_group_ptr->min_id)
@ -13612,7 +13610,7 @@ elf32_nds32_unify_relax_group (bfd *abfd, asection *asec)
} }
while (FALSE); while (FALSE);
if (relocs != NULL && elf_section_data (asec)->relocs != relocs) if (elf_section_data (asec)->relocs != relocs)
free (relocs); free (relocs);
return result; return result;
@ -14038,15 +14036,13 @@ nds32_elf_unify_tls_model (bfd *inbfd, asection *insec, bfd_byte *incontents,
if (incontents) if (incontents)
contents = NULL; contents = NULL;
if (internal_relocs != NULL if (elf_section_data (insec)->relocs != internal_relocs)
&& elf_section_data (insec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
if (contents != NULL if (elf_section_data (insec)->this_hdr.contents != contents)
&& elf_section_data (insec)->this_hdr.contents != contents)
free (contents); free (contents);
if (local_syms != NULL && symtab_hdr->contents != (bfd_byte *) local_syms) if (symtab_hdr->contents != (bfd_byte *) local_syms)
free (local_syms); free (local_syms);
if (chain.next) if (chain.next)

View File

@ -4538,8 +4538,7 @@ nios2_elf32_relocate_section (bfd *output_bfd,
{ {
(*info->callbacks->warning) (info, msg, name, input_bfd, (*info->callbacks->warning) (info, msg, name, input_bfd,
input_section, rel->r_offset); input_section, rel->r_offset);
if (msgbuf) free (msgbuf);
free (msgbuf);
return FALSE; return FALSE;
} }
} }

View File

@ -1633,8 +1633,7 @@ ppc_elf_begin_write_processing (bfd *abfd, struct bfd_link_info *link_info)
apuinfo_set = TRUE; apuinfo_set = TRUE;
if (largest_input_size < asec->size) if (largest_input_size < asec->size)
{ {
if (buffer) free (buffer);
free (buffer);
largest_input_size = asec->size; largest_input_size = asec->size;
buffer = bfd_malloc (largest_input_size); buffer = bfd_malloc (largest_input_size);
if (!buffer) if (!buffer)
@ -1692,8 +1691,7 @@ ppc_elf_begin_write_processing (bfd *abfd, struct bfd_link_info *link_info)
} }
fail: fail:
if (buffer) free (buffer);
free (buffer);
if (error_message) if (error_message)
_bfd_error_handler (error_message, APUINFO_SECTION_NAME, ibfd); _bfd_error_handler (error_message, APUINFO_SECTION_NAME, ibfd);
@ -4263,8 +4261,7 @@ ppc_elf_inline_plt (struct bfd_link_info *info)
{ {
if (elf_section_data (sec)->relocs != relstart) if (elf_section_data (sec)->relocs != relstart)
free (relstart); free (relstart);
if (local_syms != NULL if (symtab_hdr->contents != (unsigned char *) local_syms)
&& symtab_hdr->contents != (unsigned char *) local_syms)
free (local_syms); free (local_syms);
return FALSE; return FALSE;
} }
@ -6651,8 +6648,7 @@ ppc_elf_relax_section (bfd *abfd,
rel_hdr = _bfd_elf_single_rel_hdr (isec); rel_hdr = _bfd_elf_single_rel_hdr (isec);
rel_hdr->sh_size += changes * rel_hdr->sh_entsize; rel_hdr->sh_size += changes * rel_hdr->sh_entsize;
} }
else if (internal_relocs != NULL else if (elf_section_data (isec)->relocs != internal_relocs)
&& elf_section_data (isec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
*again = changes != 0 || workaround_change; *again = changes != 0 || workaround_change;
@ -6665,13 +6661,11 @@ ppc_elf_relax_section (bfd *abfd,
branch_fixups = branch_fixups->next; branch_fixups = branch_fixups->next;
free (f); free (f);
} }
if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents) if ((unsigned char *) isymbuf != symtab_hdr->contents)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (isec)->this_hdr.contents != contents)
&& elf_section_data (isec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (isec)->relocs != internal_relocs)
&& elf_section_data (isec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
} }
@ -9710,8 +9704,7 @@ ppc_finish_symbols (struct bfd_link_info *info)
if (!get_sym_h (NULL, &sym, &sym_sec, NULL, &local_syms, if (!get_sym_h (NULL, &sym, &sym_sec, NULL, &local_syms,
lplt - local_plt, ibfd)) lplt - local_plt, ibfd))
{ {
if (local_syms != NULL if (symtab_hdr->contents != (unsigned char *) local_syms)
&& symtab_hdr->contents != (unsigned char *) local_syms)
free (local_syms); free (local_syms);
return FALSE; return FALSE;
} }

View File

@ -1523,20 +1523,17 @@ pru_elf32_relax_section (bfd * abfd, asection * sec,
} }
} }
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf) if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;

View File

@ -2552,11 +2552,8 @@ rl78_elf_relax_section
return TRUE; return TRUE;
error_return: error_return:
if (free_relocs != NULL) free (free_relocs);
free (free_relocs); free (free_contents);
if (free_contents != NULL)
free (free_contents);
if (shndx_buf != NULL) if (shndx_buf != NULL)
{ {
@ -2564,8 +2561,7 @@ rl78_elf_relax_section
free (shndx_buf); free (shndx_buf);
} }
if (free_intsyms != NULL) free (free_intsyms);
free (free_intsyms);
return TRUE; return TRUE;
} }

View File

@ -3037,8 +3037,7 @@ elf32_rx_relax_section (bfd * abfd,
return TRUE; return TRUE;
error_return: error_return:
if (free_contents != NULL) free (free_contents);
free (free_contents);
if (shndx_buf != NULL) if (shndx_buf != NULL)
{ {
@ -3046,8 +3045,7 @@ elf32_rx_relax_section (bfd * abfd,
free (shndx_buf); free (shndx_buf);
} }
if (free_intsyms != NULL) free (free_intsyms);
free (free_intsyms);
return FALSE; return FALSE;
} }

View File

@ -167,8 +167,7 @@ sh_elf_reloc_loop (int r_type ATTRIBUTE_UNUSED, bfd *input_bfd,
if (!bfd_malloc_and_get_section (input_bfd, symbol_section, if (!bfd_malloc_and_get_section (input_bfd, symbol_section,
&contents)) &contents))
{ {
if (contents != NULL) free (contents);
free (contents);
return bfd_reloc_outofrange; return bfd_reloc_outofrange;
} }
} }
@ -203,8 +202,7 @@ sh_elf_reloc_loop (int r_type ATTRIBUTE_UNUSED, bfd *input_bfd,
end = start0; end = start0;
} }
if (contents != NULL if (elf_section_data (symbol_section)->this_hdr.contents != contents)
&& elf_section_data (symbol_section)->this_hdr.contents != contents)
free (contents); free (contents);
insn = bfd_get_16 (input_bfd, contents + addr); insn = bfd_get_16 (input_bfd, contents + addr);
@ -811,21 +809,17 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
} }
} }
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL if (symtab_hdr->contents != (unsigned char *) isymbuf)
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
@ -1195,8 +1189,7 @@ sh_elf_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr,
when we leave sh_coff_relax_section. */ when we leave sh_coff_relax_section. */
if (!bfd_malloc_and_get_section (abfd, o, &ocontents)) if (!bfd_malloc_and_get_section (abfd, o, &ocontents))
{ {
if (ocontents != NULL) free (ocontents);
free (ocontents);
return FALSE; return FALSE;
} }
@ -1253,8 +1246,7 @@ sh_elf_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr,
when we leave sh_coff_relax_section. */ when we leave sh_coff_relax_section. */
if (!bfd_malloc_and_get_section (abfd, o, &ocontents)) if (!bfd_malloc_and_get_section (abfd, o, &ocontents))
{ {
if (ocontents != NULL) free (ocontents);
free (ocontents);
return FALSE; return FALSE;
} }
@ -1387,8 +1379,7 @@ sh_elf_align_loads (bfd *abfd ATTRIBUTE_UNUSED, asection *sec,
return TRUE; return TRUE;
error_return: error_return:
if (labels != NULL) free (labels);
free (labels);
return FALSE; return FALSE;
} }
@ -5257,10 +5248,8 @@ sh_elf_get_relocated_section_contents (bfd *output_bfd,
isymbuf, sections)) isymbuf, sections))
goto error_return; goto error_return;
if (sections != NULL) free (sections);
free (sections); if (symtab_hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (elf_section_data (input_section)->relocs != internal_relocs) if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
@ -5269,13 +5258,10 @@ sh_elf_get_relocated_section_contents (bfd *output_bfd,
return data; return data;
error_return: error_return:
if (sections != NULL) free (sections);
free (sections); if (symtab_hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (internal_relocs != NULL if (elf_section_data (input_section)->relocs != internal_relocs)
&& elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return NULL; return NULL;
} }

View File

@ -1598,9 +1598,7 @@ process_stubs (struct bfd_link_info *info, bfd_boolean build)
if (elf_section_data (isec)->relocs != internal_relocs) if (elf_section_data (isec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
error_ret_free_local: error_ret_free_local:
if (local_syms != NULL if (symtab_hdr->contents != (unsigned char *) local_syms)
&& (symtab_hdr->contents
!= (unsigned char *) local_syms))
free (local_syms); free (local_syms);
return FALSE; return FALSE;
} }
@ -3013,13 +3011,10 @@ discover_functions (struct bfd_link_info *info)
continue; continue;
} }
if (symtab_hdr->contents != NULL) /* Don't use cached symbols since the generic ELF linker
{ code only reads local symbols, and we need globals too. */
/* Don't use cached symbols since the generic ELF linker free (symtab_hdr->contents);
code only reads local symbols, and we need globals too. */ symtab_hdr->contents = NULL;
free (symtab_hdr->contents);
symtab_hdr->contents = NULL;
}
syms = bfd_elf_get_elf_syms (ibfd, symtab_hdr, symcount, 0, syms = bfd_elf_get_elf_syms (ibfd, symtab_hdr, symcount, 0,
NULL, NULL, NULL); NULL, NULL, NULL);
symtab_hdr->contents = (void *) syms; symtab_hdr->contents = (void *) syms;

View File

@ -4093,16 +4093,13 @@ v850_elf_relax_section (bfd *abfd,
} }
finish: finish:
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != (unsigned char *) contents)
&& elf_section_data (sec)->this_hdr.contents != (unsigned char *) contents)
free (contents); free (contents);
if (isymbuf != NULL if (symtab_hdr->contents != (bfd_byte *) isymbuf)
&& symtab_hdr->contents != (bfd_byte *) isymbuf)
free (isymbuf); free (isymbuf);
return result; return result;

View File

@ -3048,9 +3048,7 @@ elf_xtensa_relocate_section (bfd *output_bfd,
} }
} }
if (lit_table) free (lit_table);
free (lit_table);
input_section->reloc_done = TRUE; input_section->reloc_done = TRUE;
return TRUE; return TRUE;
@ -3130,8 +3128,7 @@ elf_xtensa_combine_prop_entries (bfd *output_bfd,
if (!bfd_malloc_and_get_section (output_bfd, sxtlit, &contents)) if (!bfd_malloc_and_get_section (output_bfd, sxtlit, &contents))
{ {
if (contents != 0) free (contents);
free (contents);
free (table); free (table);
return -1; return -1;
} }
@ -6295,8 +6292,7 @@ free_section_cache (section_cache_t *sec_cache)
{ {
release_contents (sec_cache->sec, sec_cache->contents); release_contents (sec_cache->sec, sec_cache->contents);
release_internal_relocs (sec_cache->sec, sec_cache->relocs); release_internal_relocs (sec_cache->sec, sec_cache->relocs);
if (sec_cache->ptbl) free (sec_cache->ptbl);
free (sec_cache->ptbl);
} }
} }
@ -6353,8 +6349,7 @@ section_cache_section (section_cache_t *sec_cache,
err: err:
release_contents (sec, contents); release_contents (sec, contents);
release_internal_relocs (sec, internal_relocs); release_internal_relocs (sec, internal_relocs);
if (prop_table) free (prop_table);
free (prop_table);
return FALSE; return FALSE;
} }
@ -6473,8 +6468,7 @@ init_ebb_constraint (ebb_constraint *c)
static void static void
free_ebb_constraint (ebb_constraint *c) free_ebb_constraint (ebb_constraint *c)
{ {
if (c->actions) free (c->actions);
free (c->actions);
} }
@ -6708,8 +6702,7 @@ ebb_propose_action (ebb_constraint *c,
for (i = 0; i < c->action_count; i++) for (i = 0; i < c->action_count; i++)
new_actions[i] = c->actions[i]; new_actions[i] = c->actions[i];
if (c->actions) free (c->actions);
free (c->actions);
c->actions = new_actions; c->actions = new_actions;
c->action_allocated = new_allocated; c->action_allocated = new_allocated;
} }
@ -6761,8 +6754,7 @@ pin_internal_relocs (asection *sec, Elf_Internal_Rela *internal_relocs)
static void static void
release_internal_relocs (asection *sec, Elf_Internal_Rela *internal_relocs) release_internal_relocs (asection *sec, Elf_Internal_Rela *internal_relocs)
{ {
if (internal_relocs if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
} }
@ -6780,8 +6772,7 @@ retrieve_contents (bfd *abfd, asection *sec, bfd_boolean keep_memory)
{ {
if (!bfd_malloc_and_get_section (abfd, sec, &contents)) if (!bfd_malloc_and_get_section (abfd, sec, &contents))
{ {
if (contents) free (contents);
free (contents);
return NULL; return NULL;
} }
if (keep_memory) if (keep_memory)
@ -6801,7 +6792,7 @@ pin_contents (asection *sec, bfd_byte *contents)
static void static void
release_contents (asection *sec, bfd_byte *contents) release_contents (asection *sec, bfd_byte *contents)
{ {
if (contents && elf_section_data (sec)->this_hdr.contents != contents) if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
} }
@ -7886,10 +7877,8 @@ compute_text_actions (bfd *abfd,
error_return: error_return:
release_contents (sec, contents); release_contents (sec, contents);
release_internal_relocs (sec, internal_relocs); release_internal_relocs (sec, internal_relocs);
if (prop_table) free (prop_table);
free (prop_table); free (reloc_opcodes);
if (reloc_opcodes)
free (reloc_opcodes);
return ok; return ok;
} }
@ -8489,10 +8478,11 @@ build_xlate_map (asection *sec, xtensa_relax_info *relax_info)
static void static void
free_xlate_map (xlate_map_t *map) free_xlate_map (xlate_map_t *map)
{ {
if (map && map->entry)
free (map->entry);
if (map) if (map)
free (map); {
free (map->entry);
free (map);
}
} }
@ -8676,8 +8666,7 @@ check_section_ebb_pcrels_fit (bfd *abfd,
} }
} }
if (xmap) free_xlate_map (xmap);
free_xlate_map (xmap);
return ok; return ok;
} }
@ -8889,8 +8878,7 @@ compute_removed_literals (bfd *abfd,
#endif /* DEBUG */ #endif /* DEBUG */
error_return: error_return:
if (prop_table) free (prop_table);
free (prop_table);
free_section_cache (&target_sec_cache); free_section_cache (&target_sec_cache);
release_contents (sec, contents); release_contents (sec, contents);

View File

@ -1422,30 +1422,18 @@ elf64_alpha_read_ecoff_info (bfd *abfd, asection *section,
return TRUE; return TRUE;
error_return: error_return:
if (ext_hdr != NULL) free (ext_hdr);
free (ext_hdr); free (debug->line);
if (debug->line != NULL) free (debug->external_dnr);
free (debug->line); free (debug->external_pdr);
if (debug->external_dnr != NULL) free (debug->external_sym);
free (debug->external_dnr); free (debug->external_opt);
if (debug->external_pdr != NULL) free (debug->external_aux);
free (debug->external_pdr); free (debug->ss);
if (debug->external_sym != NULL) free (debug->ssext);
free (debug->external_sym); free (debug->external_fdr);
if (debug->external_opt != NULL) free (debug->external_rfd);
free (debug->external_opt); free (debug->external_ext);
if (debug->external_aux != NULL)
free (debug->external_aux);
if (debug->ss != NULL)
free (debug->ss);
if (debug->ssext != NULL)
free (debug->ssext);
if (debug->external_fdr != NULL)
free (debug->external_fdr);
if (debug->external_rfd != NULL)
free (debug->external_rfd);
if (debug->external_ext != NULL)
free (debug->external_ext);
return FALSE; return FALSE;
} }
@ -3186,12 +3174,10 @@ elf64_alpha_relax_opt_call (struct alpha_relax_info *info, bfd_vma symval)
if (!gpdisp || gpdisp->r_addend != 4) if (!gpdisp || gpdisp->r_addend != 4)
{ {
if (tsec_free) free (tsec_free);
free (tsec_free);
return 0; return 0;
} }
if (tsec_free) free (tsec_free);
free (tsec_free);
} }
/* We've now determined that we can skip an initial gp load. Verify /* We've now determined that we can skip an initial gp load. Verify
@ -4037,14 +4023,11 @@ elf64_alpha_relax_section (bfd *abfd, asection *sec,
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL if (symtab_hdr->contents != (unsigned char *) isymbuf)
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (info.contents != NULL if (elf_section_data (sec)->this_hdr.contents != info.contents)
&& elf_section_data (sec)->this_hdr.contents != info.contents)
free (info.contents); free (info.contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
} }

View File

@ -534,8 +534,7 @@ elf64_hppa_check_relocs (bfd *abfd,
?!? Note we leak the last section_syms array. Presumably we ?!? Note we leak the last section_syms array. Presumably we
could free it in one of the later routines in this file. */ could free it in one of the later routines in this file. */
if (hppa_info->section_syms) free (hppa_info->section_syms);
free (hppa_info->section_syms);
/* Read this BFD's local symbols. */ /* Read this BFD's local symbols. */
if (symtab_hdr->sh_info != 0) if (symtab_hdr->sh_info != 0)

View File

@ -792,13 +792,11 @@ elf64_ia64_relax_section (bfd *abfd, asection *sec,
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents) if ((unsigned char *) isymbuf != symtab_hdr->contents)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
} }
@ -999,14 +997,11 @@ elf64_ia64_global_dyn_info_free (void **xentry,
if (entry->root.root.type == bfd_link_hash_warning) if (entry->root.root.type == bfd_link_hash_warning)
entry = (struct elf64_ia64_link_hash_entry *) entry->root.root.u.i.link; entry = (struct elf64_ia64_link_hash_entry *) entry->root.root.u.i.link;
if (entry->info) free (entry->info);
{ entry->info = NULL;
free (entry->info); entry->count = 0;
entry->info = NULL; entry->sorted_count = 0;
entry->count = 0; entry->size = 0;
entry->sorted_count = 0;
entry->size = 0;
}
return TRUE; return TRUE;
} }
@ -1020,14 +1015,11 @@ elf64_ia64_local_dyn_info_free (void **slot,
struct elf64_ia64_local_hash_entry *entry struct elf64_ia64_local_hash_entry *entry
= (struct elf64_ia64_local_hash_entry *) *slot; = (struct elf64_ia64_local_hash_entry *) *slot;
if (entry->info) free (entry->info);
{ entry->info = NULL;
free (entry->info); entry->count = 0;
entry->info = NULL; entry->sorted_count = 0;
entry->count = 0; entry->size = 0;
entry->sorted_count = 0;
entry->size = 0;
}
return TRUE; return TRUE;
} }
@ -5242,11 +5234,8 @@ elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
} }
} }
if (isymbuf != NULL) free (isymbuf);
{ isymbuf = NULL;
free (isymbuf);
isymbuf = NULL;
}
/* If this object is the same format as the output object, and it is /* If this object is the same format as the output object, and it is
not a shared library, then let the backend look through the not a shared library, then let the backend look through the
@ -5303,8 +5292,7 @@ elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
error_free_vers: error_free_vers:
error_free_sym: error_free_sym:
if (isymbuf != NULL) free (isymbuf);
free (isymbuf);
error_return: error_return:
return FALSE; return FALSE;
} }

View File

@ -4162,14 +4162,11 @@ mips_elf64_slurp_one_reloc_table (bfd *abfd, asection *asect,
} }
} }
if (allocated != NULL) free (allocated);
free (allocated);
return TRUE; return TRUE;
error_return: error_return:
if (allocated != NULL) free (allocated);
free (allocated);
return FALSE; return FALSE;
} }

View File

@ -2844,8 +2844,7 @@ mmix_elf_relax_section (bfd *abfd,
BFD_ASSERT(pjsno == mmix_elf_section_data (sec)->pjs.n_pushj_relocs); BFD_ASSERT(pjsno == mmix_elf_section_data (sec)->pjs.n_pushj_relocs);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
if (sec->size < size + mmix_elf_section_data (sec)->pjs.stubs_size_sum) if (sec->size < size + mmix_elf_section_data (sec)->pjs.stubs_size_sum)
@ -2860,10 +2859,9 @@ mmix_elf_relax_section (bfd *abfd,
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents) if ((unsigned char *) isymbuf != symtab_hdr->contents)
free (isymbuf); free (isymbuf);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
} }

View File

@ -2422,8 +2422,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
free_contents_and_exit_err: free_contents_and_exit_err:
count = -1; count = -1;
free_contents_and_exit: free_contents_and_exit:
if (contents) free (contents);
free (contents);
goto done; goto done;
} }
@ -7303,11 +7302,9 @@ ppc64_elf_edit_opd (struct bfd_link_info *info)
bfd_byte *loc; bfd_byte *loc;
if (!bfd_malloc_and_get_section (ibfd, sec, &loc)) if (!bfd_malloc_and_get_section (ibfd, sec, &loc))
{ {
if (loc != NULL) free (loc);
free (loc);
error_ret: error_ret:
if (local_syms != NULL if (symtab_hdr->contents != (unsigned char *) local_syms)
&& symtab_hdr->contents != (unsigned char *) local_syms)
free (local_syms); free (local_syms);
if (elf_section_data (sec)->relocs != relstart) if (elf_section_data (sec)->relocs != relstart)
free (relstart); free (relstart);
@ -7633,8 +7630,7 @@ ppc64_elf_inline_plt (struct bfd_link_info *info)
{ {
if (elf_section_data (sec)->relocs != relstart) if (elf_section_data (sec)->relocs != relstart)
free (relstart); free (relstart);
if (local_syms != NULL if (symtab_hdr->contents != (bfd_byte *) local_syms)
&& symtab_hdr->contents != (bfd_byte *) local_syms)
free (local_syms); free (local_syms);
return FALSE; return FALSE;
} }
@ -7975,11 +7971,9 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info)
err_free_rel: err_free_rel:
if (elf_section_data (sec)->relocs != relstart) if (elf_section_data (sec)->relocs != relstart)
free (relstart); free (relstart);
if (toc_ref != NULL) free (toc_ref);
free (toc_ref); if (elf_symtab_hdr (ibfd).contents
if (locsyms != NULL != (unsigned char *) locsyms)
&& (elf_symtab_hdr (ibfd).contents
!= (unsigned char *) locsyms))
free (locsyms); free (locsyms);
return ret; return ret;
} }
@ -8394,8 +8388,7 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info)
} }
} }
if (toc_ref != NULL) free (toc_ref);
free (toc_ref);
htab->do_tls_opt = 1; htab->do_tls_opt = 1;
return TRUE; return TRUE;
} }
@ -8835,18 +8828,14 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
if (used == NULL) if (used == NULL)
{ {
error_ret: error_ret:
if (local_syms != NULL if (symtab_hdr->contents != (unsigned char *) local_syms)
&& symtab_hdr->contents != (unsigned char *) local_syms)
free (local_syms); free (local_syms);
if (sec != NULL if (sec != NULL
&& relstart != NULL
&& elf_section_data (sec)->relocs != relstart) && elf_section_data (sec)->relocs != relstart)
free (relstart); free (relstart);
if (toc_relocs != NULL if (elf_section_data (toc)->relocs != toc_relocs)
&& elf_section_data (toc)->relocs != toc_relocs)
free (toc_relocs); free (toc_relocs);
if (skip != NULL) free (skip);
free (skip);
return FALSE; return FALSE;
} }
@ -9213,8 +9202,7 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
rel_hdr->sh_size = toc->reloc_count * sz; rel_hdr->sh_size = toc->reloc_count * sz;
} }
} }
else if (toc_relocs != NULL else if (elf_section_data (toc)->relocs != toc_relocs)
&& elf_section_data (toc)->relocs != toc_relocs)
free (toc_relocs); free (toc_relocs);
if (local_syms != NULL if (local_syms != NULL
@ -9265,11 +9253,9 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
if (relstart == NULL) if (relstart == NULL)
{ {
got_error_ret: got_error_ret:
if (local_syms != NULL if (symtab_hdr->contents != (unsigned char *) local_syms)
&& symtab_hdr->contents != (unsigned char *) local_syms)
free (local_syms); free (local_syms);
if (sec != NULL if (sec != NULL
&& relstart != NULL
&& elf_section_data (sec)->relocs != relstart) && elf_section_data (sec)->relocs != relstart)
free (relstart); free (relstart);
return FALSE; return FALSE;
@ -12792,9 +12778,8 @@ toc_adjusting_stub_needed (struct bfd_link_info *info, asection *isec)
} }
} }
if (local_syms != NULL if (elf_symtab_hdr (isec->owner).contents
&& (elf_symtab_hdr (isec->owner).contents != (unsigned char *) local_syms)
!= (unsigned char *) local_syms))
free (local_syms); free (local_syms);
if (elf_section_data (isec)->relocs != relstart) if (elf_section_data (isec)->relocs != relstart)
free (relstart); free (relstart);
@ -13547,9 +13532,8 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
if (elf_section_data (section)->relocs == NULL) if (elf_section_data (section)->relocs == NULL)
free (internal_relocs); free (internal_relocs);
error_ret_free_local: error_ret_free_local:
if (local_syms != NULL if (symtab_hdr->contents
&& (symtab_hdr->contents != (unsigned char *) local_syms)
!= (unsigned char *) local_syms))
free (local_syms); free (local_syms);
return FALSE; return FALSE;
} }
@ -14120,8 +14104,7 @@ write_plt_relocs_for_local_syms (struct bfd_link_info *info)
if (!get_sym_h (NULL, &sym, &sym_sec, NULL, &local_syms, if (!get_sym_h (NULL, &sym, &sym_sec, NULL, &local_syms,
lplt - local_plt, ibfd)) lplt - local_plt, ibfd))
{ {
if (local_syms != NULL if (symtab_hdr->contents != (unsigned char *) local_syms)
&& symtab_hdr->contents != (unsigned char *) local_syms)
free (local_syms); free (local_syms);
return FALSE; return FALSE;
} }
@ -17199,8 +17182,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
reloc_name, sym_name, (int) r); reloc_name, sym_name, (int) r);
ret = FALSE; ret = FALSE;
} }
if (more_info != NULL) free (more_info);
free (more_info);
} }
copy_reloc: copy_reloc:
if (wrel != rel) if (wrel != rel)

View File

@ -161,14 +161,11 @@ elf64_sparc_slurp_one_reloc_table (bfd *abfd, asection *asect,
canon_reloc_count (asect) += relent - relents; canon_reloc_count (asect) += relent - relents;
if (allocated != NULL) free (allocated);
free (allocated);
return TRUE; return TRUE;
error_return: error_return:
if (allocated != NULL) free (allocated);
free (allocated);
return FALSE; return FALSE;
} }

View File

@ -1144,8 +1144,7 @@ elf_checksum_contents (bfd *abfd,
if (contents != NULL) if (contents != NULL)
{ {
(*process) (contents, i_shdr.sh_size, arg); (*process) (contents, i_shdr.sh_size, arg);
if (free_contents != NULL) free (free_contents);
free (free_contents);
} }
} }
@ -1402,16 +1401,14 @@ elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic)
*symptrs = 0; /* Final null pointer */ *symptrs = 0; /* Final null pointer */
} }
if (xverbuf != NULL) free (xverbuf);
free (xverbuf); if (hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL && hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
return symcount; return symcount;
error_return: error_return:
if (xverbuf != NULL) free (xverbuf);
free (xverbuf); if (hdr->contents != (unsigned char *) isymbuf)
if (isymbuf != NULL && hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
return -1; return -1;
} }
@ -1509,13 +1506,11 @@ elf_slurp_reloc_table_from_section (bfd *abfd,
goto error_return; goto error_return;
} }
if (allocated != NULL) free (allocated);
free (allocated);
return TRUE; return TRUE;
error_return: error_return:
if (allocated != NULL) free (allocated);
free (allocated);
return FALSE; return FALSE;
} }

View File

@ -2643,8 +2643,7 @@ _bfd_elf_link_read_relocs (bfd *abfd,
if (keep_memory) if (keep_memory)
esdo->relocs = internal_relocs; esdo->relocs = internal_relocs;
if (alloc1 != NULL) free (alloc1);
free (alloc1);
/* Don't free alloc2, since if it was allocated we are passing it /* Don't free alloc2, since if it was allocated we are passing it
back (under the name of internal_relocs). */ back (under the name of internal_relocs). */
@ -2652,8 +2651,7 @@ _bfd_elf_link_read_relocs (bfd *abfd,
return internal_relocs; return internal_relocs;
error_return: error_return:
if (alloc1 != NULL) free (alloc1);
free (alloc1);
if (alloc2 != NULL) if (alloc2 != NULL)
{ {
if (keep_memory) if (keep_memory)
@ -5299,17 +5297,10 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
} }
} }
if (extversym != NULL) free (extversym);
{ extversym = NULL;
free (extversym); free (isymbuf);
extversym = NULL; isymbuf = NULL;
}
if (isymbuf != NULL)
{
free (isymbuf);
isymbuf = NULL;
}
if ((elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0) if ((elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0)
{ {
@ -5389,8 +5380,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
free (old_tab); free (old_tab);
objalloc_free_block ((struct objalloc *) htab->root.table.memory, objalloc_free_block ((struct objalloc *) htab->root.table.memory,
alloc_mark); alloc_mark);
if (nondeflt_vers != NULL) free (nondeflt_vers);
free (nondeflt_vers);
return TRUE; return TRUE;
} }
@ -5673,17 +5663,12 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
return TRUE; return TRUE;
error_free_vers: error_free_vers:
if (old_tab != NULL) free (old_tab);
free (old_tab); free (old_strtab);
if (old_strtab != NULL) free (nondeflt_vers);
free (old_strtab); free (extversym);
if (nondeflt_vers != NULL)
free (nondeflt_vers);
if (extversym != NULL)
free (extversym);
error_free_sym: error_free_sym:
if (isymbuf != NULL) free (isymbuf);
free (isymbuf);
error_return: error_return:
return FALSE; return FALSE;
} }
@ -5891,12 +5876,10 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
while (loop); while (loop);
free (included); free (included);
return TRUE; return TRUE;
error_return: error_return:
if (included != NULL) free (included);
free (included);
return FALSE; return FALSE;
} }
@ -5967,9 +5950,7 @@ elf_collect_hash_codes (struct elf_link_hash_entry *h, void *data)
later. */ later. */
h->u.elf_hash_value = ha; h->u.elf_hash_value = ha;
if (alc != NULL) free (alc);
free (alc);
return TRUE; return TRUE;
} }
@ -6043,9 +6024,7 @@ elf_collect_gnu_hash_codes (struct elf_link_hash_entry *h, void *data)
if (s->min_dynindx < 0 || s->min_dynindx > h->dynindx) if (s->min_dynindx < 0 || s->min_dynindx > h->dynindx)
s->min_dynindx = h->dynindx; s->min_dynindx = h->dynindx;
if (alc != NULL) free (alc);
free (alc);
return TRUE; return TRUE;
} }
@ -7973,8 +7952,7 @@ bfd_elf_get_bfd_needed_list (bfd *abfd,
return TRUE; return TRUE;
error_return: error_return:
if (dynbuf != NULL) free (dynbuf);
free (dynbuf);
return FALSE; return FALSE;
} }
@ -8313,14 +8291,10 @@ bfd_elf_match_symbols_in_sections (asection *sec1, asection *sec2,
result = TRUE; result = TRUE;
done: done:
if (symtable1) free (symtable1);
free (symtable1); free (symtable2);
if (symtable2) free (isymbuf1);
free (symtable2); free (isymbuf2);
if (isymbuf1)
free (isymbuf1);
if (isymbuf2)
free (isymbuf2);
return result; return result;
} }
@ -11875,32 +11849,21 @@ elf_final_link_free (bfd *obfd, struct elf_final_link_info *flinfo)
if (flinfo->symstrtab != NULL) if (flinfo->symstrtab != NULL)
_bfd_elf_strtab_free (flinfo->symstrtab); _bfd_elf_strtab_free (flinfo->symstrtab);
if (flinfo->contents != NULL) free (flinfo->contents);
free (flinfo->contents); free (flinfo->external_relocs);
if (flinfo->external_relocs != NULL) free (flinfo->internal_relocs);
free (flinfo->external_relocs); free (flinfo->external_syms);
if (flinfo->internal_relocs != NULL) free (flinfo->locsym_shndx);
free (flinfo->internal_relocs); free (flinfo->internal_syms);
if (flinfo->external_syms != NULL) free (flinfo->indices);
free (flinfo->external_syms); free (flinfo->sections);
if (flinfo->locsym_shndx != NULL) if (flinfo->symshndxbuf != (Elf_External_Sym_Shndx *) -1)
free (flinfo->locsym_shndx);
if (flinfo->internal_syms != NULL)
free (flinfo->internal_syms);
if (flinfo->indices != NULL)
free (flinfo->indices);
if (flinfo->sections != NULL)
free (flinfo->sections);
if (flinfo->symshndxbuf != NULL
&& flinfo->symshndxbuf != (Elf_External_Sym_Shndx *) -1)
free (flinfo->symshndxbuf); free (flinfo->symshndxbuf);
for (o = obfd->sections; o != NULL; o = o->next) for (o = obfd->sections; o != NULL; o = o->next)
{ {
struct bfd_elf_section_data *esdo = elf_section_data (o); struct bfd_elf_section_data *esdo = elf_section_data (o);
if ((o->flags & SEC_RELOC) != 0 && esdo->rel.hashes != NULL) free (esdo->rel.hashes);
free (esdo->rel.hashes); free (esdo->rela.hashes);
if ((o->flags & SEC_RELOC) != 0 && esdo->rela.hashes != NULL)
free (esdo->rela.hashes);
} }
} }
@ -12488,8 +12451,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
if (!info->reduce_memory_overheads) if (!info->reduce_memory_overheads)
{ {
for (sub = info->input_bfds; sub != NULL; sub = sub->link.next) for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
if (bfd_get_flavour (sub) == bfd_target_elf_flavour if (bfd_get_flavour (sub) == bfd_target_elf_flavour)
&& elf_tdata (sub)->symbuf)
{ {
free (elf_tdata (sub)->symbuf); free (elf_tdata (sub)->symbuf);
elf_tdata (sub)->symbuf = NULL; elf_tdata (sub)->symbuf = NULL;
@ -13097,8 +13059,7 @@ fini_reloc_cookie (struct elf_reloc_cookie *cookie, bfd *abfd)
Elf_Internal_Shdr *symtab_hdr; Elf_Internal_Shdr *symtab_hdr;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
if (cookie->locsyms != NULL if (symtab_hdr->contents != (unsigned char *) cookie->locsyms)
&& symtab_hdr->contents != (unsigned char *) cookie->locsyms)
free (cookie->locsyms); free (cookie->locsyms);
} }
@ -13135,7 +13096,7 @@ static void
fini_reloc_cookie_rels (struct elf_reloc_cookie *cookie, fini_reloc_cookie_rels (struct elf_reloc_cookie *cookie,
asection *sec) asection *sec)
{ {
if (cookie->rels && elf_section_data (sec)->relocs != cookie->rels) if (elf_section_data (sec)->relocs != cookie->rels)
free (cookie->rels); free (cookie->rels);
} }

View File

@ -873,13 +873,11 @@ elfNN_ia64_relax_section (bfd *abfd, asection *sec,
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents) if ((unsigned char *) isymbuf != symtab_hdr->contents)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;
} }
@ -1310,8 +1308,7 @@ elfNN_ia64_hash_copy_indirect (struct bfd_link_info *info,
struct elfNN_ia64_dyn_sym_info *dyn_i; struct elfNN_ia64_dyn_sym_info *dyn_i;
unsigned int count; unsigned int count;
if (dir->info) free (dir->info);
free (dir->info);
dir->info = ind->info; dir->info = ind->info;
dir->count = ind->count; dir->count = ind->count;
@ -1399,14 +1396,11 @@ elfNN_ia64_global_dyn_info_free (void **xentry,
struct elfNN_ia64_link_hash_entry *entry struct elfNN_ia64_link_hash_entry *entry
= (struct elfNN_ia64_link_hash_entry *) xentry; = (struct elfNN_ia64_link_hash_entry *) xentry;
if (entry->info) free (entry->info);
{ entry->info = NULL;
free (entry->info); entry->count = 0;
entry->info = NULL; entry->sorted_count = 0;
entry->count = 0; entry->size = 0;
entry->sorted_count = 0;
entry->size = 0;
}
return TRUE; return TRUE;
} }
@ -1420,14 +1414,11 @@ elfNN_ia64_local_dyn_info_free (void **slot,
struct elfNN_ia64_local_hash_entry *entry struct elfNN_ia64_local_hash_entry *entry
= (struct elfNN_ia64_local_hash_entry *) *slot; = (struct elfNN_ia64_local_hash_entry *) *slot;
if (entry->info) free (entry->info);
{ entry->info = NULL;
free (entry->info); entry->count = 0;
entry->info = NULL; entry->sorted_count = 0;
entry->count = 0; entry->size = 0;
entry->sorted_count = 0;
entry->size = 0;
}
return TRUE; return TRUE;
} }

View File

@ -2393,9 +2393,8 @@ riscv_elf_relocate_section (bfd *output_bfd,
if (msg && r != bfd_reloc_dangerous) if (msg && r != bfd_reloc_dangerous)
info->callbacks->einfo (msg); info->callbacks->einfo (msg);
/* Free the unused `msg_buf` if needed. */ /* Free the unused `msg_buf`. */
if (msg_buf) free (msg_buf);
free (msg_buf);
/* We already reported the error via a callback, so don't try to report /* We already reported the error via a callback, so don't try to report
it again by returning false. That leads to spurious errors. */ it again by returning false. That leads to spurious errors. */

View File

@ -1450,30 +1450,18 @@ _bfd_mips_elf_read_ecoff_info (bfd *abfd, asection *section,
return TRUE; return TRUE;
error_return: error_return:
if (ext_hdr != NULL) free (ext_hdr);
free (ext_hdr); free (debug->line);
if (debug->line != NULL) free (debug->external_dnr);
free (debug->line); free (debug->external_pdr);
if (debug->external_dnr != NULL) free (debug->external_sym);
free (debug->external_dnr); free (debug->external_opt);
if (debug->external_pdr != NULL) free (debug->external_aux);
free (debug->external_pdr); free (debug->ss);
if (debug->external_sym != NULL) free (debug->ssext);
free (debug->external_sym); free (debug->external_fdr);
if (debug->external_opt != NULL) free (debug->external_rfd);
free (debug->external_opt); free (debug->external_ext);
if (debug->external_aux != NULL)
free (debug->external_aux);
if (debug->ss != NULL)
free (debug->ss);
if (debug->ssext != NULL)
free (debug->ssext);
if (debug->external_fdr != NULL)
free (debug->external_fdr);
if (debug->external_rfd != NULL)
free (debug->external_rfd);
if (debug->external_ext != NULL)
free (debug->external_ext);
return FALSE; return FALSE;
} }
@ -1618,30 +1606,19 @@ mips_elf_create_procedure_table (void *handle, bfd *abfd,
matters, but someday it might). */ matters, but someday it might). */
s->map_head.link_order = NULL; s->map_head.link_order = NULL;
if (epdr != NULL) free (epdr);
free (epdr); free (rpdr);
if (rpdr != NULL) free (esym);
free (rpdr); free (ss);
if (esym != NULL) free (sv);
free (esym);
if (ss != NULL)
free (ss);
if (sv != NULL)
free (sv);
return TRUE; return TRUE;
error_return: error_return:
if (epdr != NULL) free (epdr);
free (epdr); free (rpdr);
if (rpdr != NULL) free (esym);
free (rpdr); free (ss);
if (esym != NULL) free (sv);
free (esym);
if (ss != NULL)
free (ss);
if (sv != NULL)
free (sv);
return FALSE; return FALSE;
} }
@ -13391,13 +13368,11 @@ _bfd_elf_mips_get_relocated_section_contents
} }
} }
} }
if (reloc_vector != NULL) free (reloc_vector);
free (reloc_vector);
return data; return data;
error_return: error_return:
if (reloc_vector != NULL) free (reloc_vector);
free (reloc_vector);
return NULL; return NULL;
} }
@ -14274,21 +14249,17 @@ _bfd_mips_elf_relax_section (bfd *abfd, asection *sec,
} }
} }
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return TRUE; return TRUE;
error_return: error_return:
if (isymbuf != NULL if (symtab_hdr->contents != (unsigned char *) isymbuf)
&& symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf); free (isymbuf);
if (contents != NULL if (elf_section_data (sec)->this_hdr.contents != contents)
&& elf_section_data (sec)->this_hdr.contents != contents)
free (contents); free (contents);
if (internal_relocs != NULL if (elf_section_data (sec)->relocs != internal_relocs)
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs); free (internal_relocs);
return FALSE; return FALSE;

View File

@ -2451,8 +2451,7 @@ _bfd_x86_elf_get_synthetic_symtab (bfd *abfd,
count = n; count = n;
for (j = 0; plts[j].name != NULL; j++) for (j = 0; plts[j].name != NULL; j++)
if (plts[j].contents != NULL) free (plts[j].contents);
free (plts[j].contents);
free (dynrelbuf); free (dynrelbuf);

View File

@ -500,8 +500,7 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
if (abfd->direction == both_direction) if (abfd->direction == both_direction)
abfd->output_has_begun = TRUE; abfd->output_has_begun = TRUE;
if (matching_vector) free (matching_vector);
free (matching_vector);
if (preserve_match.marker != NULL) if (preserve_match.marker != NULL)
bfd_preserve_finish (abfd, &preserve_match); bfd_preserve_finish (abfd, &preserve_match);
bfd_preserve_finish (abfd, &preserve); bfd_preserve_finish (abfd, &preserve);
@ -519,8 +518,7 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
cleanup (abfd); cleanup (abfd);
abfd->xvec = save_targ; abfd->xvec = save_targ;
abfd->format = bfd_unknown; abfd->format = bfd_unknown;
if (matching_vector) free (matching_vector);
free (matching_vector);
if (preserve_match.marker != NULL) if (preserve_match.marker != NULL)
bfd_preserve_finish (abfd, &preserve_match); bfd_preserve_finish (abfd, &preserve_match);
bfd_preserve_restore (abfd, &preserve); bfd_preserve_restore (abfd, &preserve);
@ -544,7 +542,7 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
*(const char **) &matching_vector[match_count] = name; *(const char **) &matching_vector[match_count] = name;
} }
} }
else if (matching_vector) else
free (matching_vector); free (matching_vector);
if (cleanup) if (cleanup)
cleanup (abfd); cleanup (abfd);

View File

@ -381,8 +381,7 @@ ihex_scan (bfd *abfd)
/* An end record. */ /* An end record. */
if (abfd->start_address == 0) if (abfd->start_address == 0)
abfd->start_address = addr; abfd->start_address = addr;
if (buf != NULL) free (buf);
free (buf);
return TRUE; return TRUE;
case 2: case 2:
@ -474,14 +473,11 @@ ihex_scan (bfd *abfd)
if (error) if (error)
goto error_return; goto error_return;
if (buf != NULL) free (buf);
free (buf);
return TRUE; return TRUE;
error_return: error_return:
if (buf != NULL) free (buf);
free (buf);
return FALSE; return FALSE;
} }
@ -603,8 +599,7 @@ ihex_read_section (bfd *abfd, asection *section, bfd_byte *contents)
if ((bfd_size_type) (p - contents) >= section->size) if ((bfd_size_type) (p - contents) >= section->size)
{ {
/* We've read everything in the section. */ /* We've read everything in the section. */
if (buf != NULL) free (buf);
free (buf);
return TRUE; return TRUE;
} }
@ -621,14 +616,11 @@ ihex_read_section (bfd *abfd, asection *section, bfd_byte *contents)
goto error_return; goto error_return;
} }
if (buf != NULL) free (buf);
free (buf);
return TRUE; return TRUE;
error_return: error_return:
if (buf != NULL) free (buf);
free (buf);
return FALSE; return FALSE;
} }

View File

@ -312,7 +312,7 @@ bfd_realloc_or_free (void *ptr, bfd_size_type size)
{ {
void *ret = bfd_realloc (ptr, size); void *ret = bfd_realloc (ptr, size);
if (ret == NULL && ptr != NULL) if (ret == NULL)
free (ptr); free (ptr);
return ret; return ret;

View File

@ -2661,13 +2661,11 @@ default_indirect_link_order (bfd *output_bfd,
new_contents, loc, input_section->size)) new_contents, loc, input_section->size))
goto error_return; goto error_return;
if (contents != NULL) free (contents);
free (contents);
return TRUE; return TRUE;
error_return: error_return:
if (contents != NULL) free (contents);
free (contents);
return FALSE; return FALSE;
} }
@ -2894,10 +2892,8 @@ _bfd_handle_already_linked (asection *sec,
(_("%pB: duplicate section `%pA' has different contents\n"), (_("%pB: duplicate section `%pA' has different contents\n"),
sec->owner, sec); sec->owner, sec);
if (sec_contents) free (sec_contents);
free (sec_contents); free (l_sec_contents);
if (l_sec_contents)
free (l_sec_contents);
} }
break; break;
} }

View File

@ -2083,8 +2083,7 @@ mmo_scan (bfd *abfd)
/* Free whatever resources we took. */ /* Free whatever resources we took. */
for (i = 0; i < sizeof (file_names) / sizeof (file_names[0]); i++) for (i = 0; i < sizeof (file_names) / sizeof (file_names[0]); i++)
if (file_names[i]) free (file_names[i]);
free (file_names[i]);
return ! error; return ! error;
} }

View File

@ -1162,8 +1162,7 @@ bfd_get_debug_link_info_1 (bfd *abfd, void *crc32_out)
if (!bfd_malloc_and_get_section (abfd, sect, &contents)) if (!bfd_malloc_and_get_section (abfd, sect, &contents))
{ {
if (contents != NULL) free (contents);
free (contents);
return NULL; return NULL;
} }
@ -1252,8 +1251,7 @@ bfd_get_alt_debug_link_info (bfd * abfd, bfd_size_type *buildid_len,
if (!bfd_malloc_and_get_section (abfd, sect, & contents)) if (!bfd_malloc_and_get_section (abfd, sect, & contents))
{ {
if (contents != NULL) free (contents);
free (contents);
return NULL; return NULL;
} }
@ -1821,8 +1819,7 @@ get_build_id (bfd *abfd)
if (!bfd_malloc_and_get_section (abfd, sect, & contents)) if (!bfd_malloc_and_get_section (abfd, sect, & contents))
{ {
if (contents != NULL) free (contents);
free (contents);
return NULL; return NULL;
} }

View File

@ -2347,8 +2347,7 @@ NAME (aout, find_nearest_line) (bfd *abfd,
else else
funclen = strlen (bfd_asymbol_name (func)); funclen = strlen (bfd_asymbol_name (func));
if (adata (abfd).line_buf != NULL) free (adata (abfd).line_buf);
free (adata (abfd).line_buf);
if (filelen + funclen == 0) if (filelen + funclen == 0)
adata (abfd).line_buf = buf = NULL; adata (abfd).line_buf = buf = NULL;
else else
@ -2415,7 +2414,7 @@ NAME (aout, bfd_free_cached_info) (bfd *abfd)
if (bfd_get_format (abfd) != bfd_object) if (bfd_get_format (abfd) != bfd_object)
return TRUE; return TRUE;
#define BFCI_FREE(x) if (x != NULL) { free (x); x = NULL; } #define BFCI_FREE(x) do { free (x); x = NULL; } while (0)
BFCI_FREE (obj_aout_symbols (abfd)); BFCI_FREE (obj_aout_symbols (abfd));
#ifdef USE_MMAP #ifdef USE_MMAP
@ -3914,26 +3913,14 @@ NAME (aout, final_link) (bfd *abfd,
} }
} }
if (aout_info.contents != NULL) free (aout_info.contents);
{ aout_info.contents = NULL;
free (aout_info.contents); free (aout_info.relocs);
aout_info.contents = NULL; aout_info.relocs = NULL;
} free (aout_info.symbol_map);
if (aout_info.relocs != NULL) aout_info.symbol_map = NULL;
{ free (aout_info.output_syms);
free (aout_info.relocs); aout_info.output_syms = NULL;
aout_info.relocs = NULL;
}
if (aout_info.symbol_map != NULL)
{
free (aout_info.symbol_map);
aout_info.symbol_map = NULL;
}
if (aout_info.output_syms != NULL)
{
free (aout_info.output_syms);
aout_info.output_syms = NULL;
}
if (includes_hash_initialized) if (includes_hash_initialized)
{ {
bfd_hash_table_free (&aout_info.includes.root); bfd_hash_table_free (&aout_info.includes.root);
@ -3993,14 +3980,10 @@ NAME (aout, final_link) (bfd *abfd,
return TRUE; return TRUE;
error_return: error_return:
if (aout_info.contents != NULL) free (aout_info.contents);
free (aout_info.contents); free (aout_info.relocs);
if (aout_info.relocs != NULL) free (aout_info.symbol_map);
free (aout_info.relocs); free (aout_info.output_syms);
if (aout_info.symbol_map != NULL)
free (aout_info.symbol_map);
if (aout_info.output_syms != NULL)
free (aout_info.output_syms);
if (includes_hash_initialized) if (includes_hash_initialized)
bfd_hash_table_free (&aout_info.includes.root); bfd_hash_table_free (&aout_info.includes.root);
return FALSE; return FALSE;

View File

@ -1343,8 +1343,7 @@ pe_print_idata (bfd * abfd, void * vfile)
if (!bfd_malloc_and_get_section (abfd, rel_section, &data)) if (!bfd_malloc_and_get_section (abfd, rel_section, &data))
{ {
if (data != NULL) free (data);
free (data);
return FALSE; return FALSE;
} }
@ -1352,8 +1351,7 @@ pe_print_idata (bfd * abfd, void * vfile)
if (offset >= rel_section->size || offset + 8 > rel_section->size) if (offset >= rel_section->size || offset + 8 > rel_section->size)
{ {
if (data != NULL) free (data);
free (data);
return FALSE; return FALSE;
} }
@ -1368,8 +1366,7 @@ pe_print_idata (bfd * abfd, void * vfile)
/* xgettext:c-format */ /* xgettext:c-format */
_("\tcode-base %08lx toc (loadable/actual) %08lx/%08lx\n"), _("\tcode-base %08lx toc (loadable/actual) %08lx/%08lx\n"),
start_address, loadable_toc_address, toc_address); start_address, loadable_toc_address, toc_address);
if (data != NULL) free (data);
free (data);
} }
else else
{ {
@ -1389,8 +1386,7 @@ pe_print_idata (bfd * abfd, void * vfile)
/* Read the whole section. Some of the fields might be before dataoff. */ /* Read the whole section. Some of the fields might be before dataoff. */
if (!bfd_malloc_and_get_section (abfd, section, &data)) if (!bfd_malloc_and_get_section (abfd, section, &data))
{ {
if (data != NULL) free (data);
free (data);
return FALSE; return FALSE;
} }
@ -1935,8 +1931,7 @@ pe_print_pdata (bfd * abfd, void * vfile)
if (! bfd_malloc_and_get_section (abfd, section, &data)) if (! bfd_malloc_and_get_section (abfd, section, &data))
{ {
if (data != NULL) free (data);
free (data);
return FALSE; return FALSE;
} }
@ -2119,8 +2114,7 @@ _bfd_XX_print_ce_compressed_pdata (bfd * abfd, void * vfile)
if (! bfd_malloc_and_get_section (abfd, section, &data)) if (! bfd_malloc_and_get_section (abfd, section, &data))
{ {
if (data != NULL) free (data);
free (data);
return FALSE; return FALSE;
} }
@ -2235,8 +2229,7 @@ pe_print_reloc (bfd * abfd, void * vfile)
if (! bfd_malloc_and_get_section (abfd, section, &data)) if (! bfd_malloc_and_get_section (abfd, section, &data))
{ {
if (data != NULL) free (data);
free (data);
return FALSE; return FALSE;
} }
@ -2543,8 +2536,7 @@ rsrc_print_section (bfd * abfd, void * vfile)
if (! bfd_malloc_and_get_section (abfd, section, & data)) if (! bfd_malloc_and_get_section (abfd, section, & data))
{ {
if (data != NULL) free (data);
free (data);
return FALSE; return FALSE;
} }
@ -2688,8 +2680,7 @@ pe_print_debugdata (bfd * abfd, void * vfile)
/* Read the whole section. */ /* Read the whole section. */
if (!bfd_malloc_and_get_section (abfd, section, &data)) if (!bfd_malloc_and_get_section (abfd, section, &data))
{ {
if (data != NULL) free (data);
free (data);
return FALSE; return FALSE;
} }
@ -2786,8 +2777,7 @@ pe_is_repro (bfd * abfd)
if (!bfd_malloc_and_get_section (abfd, section, &data)) if (!bfd_malloc_and_get_section (abfd, section, &data))
{ {
if (data != NULL) free (data);
free (data);
return FALSE; return FALSE;
} }

View File

@ -505,13 +505,11 @@ bfd_pef_scan_start_address (bfd *abfd)
abfd->start_address = section->vma + header.main_offset; abfd->start_address = section->vma + header.main_offset;
end: end:
if (loaderbuf != NULL) free (loaderbuf);
free (loaderbuf);
return 0; return 0;
error: error:
if (loaderbuf != NULL) free (loaderbuf);
free (loaderbuf);
return -1; return -1;
} }
@ -868,18 +866,14 @@ bfd_pef_parse_function_stubs (bfd *abfd,
goto end; goto end;
end: end:
if (libraries != NULL) free (libraries);
free (libraries); free (imports);
if (imports != NULL)
free (imports);
*nsym = count; *nsym = count;
return 0; return 0;
error: error:
if (libraries != NULL) free (libraries);
free (libraries); free (imports);
if (imports != NULL)
free (imports);
*nsym = count; *nsym = count;
return -1; return -1;
} }
@ -941,12 +935,8 @@ bfd_pef_parse_symbols (bfd *abfd, asymbol **csym)
csym[count] = NULL; csym[count] = NULL;
end: end:
if (codebuf != NULL) free (codebuf);
free (codebuf); free (loaderbuf);
if (loaderbuf != NULL)
free (loaderbuf);
return count; return count;
} }

View File

@ -1133,8 +1133,7 @@ pe_ILF_build_a_bfd (bfd * abfd,
return TRUE; return TRUE;
error_return: error_return:
if (vars.bim->buffer != NULL) free (vars.bim->buffer);
free (vars.bim->buffer);
free (vars.bim); free (vars.bim);
return FALSE; return FALSE;
} }
@ -1350,8 +1349,7 @@ pe_bfd_read_buildid (bfd *abfd)
/* Read the whole section. */ /* Read the whole section. */
if (!bfd_malloc_and_get_section (abfd, section, &data)) if (!bfd_malloc_and_get_section (abfd, section, &data))
{ {
if (data != NULL) free (data);
free (data);
return; return;
} }

View File

@ -242,8 +242,7 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
* saved_offsets.section_count); * saved_offsets.section_count);
if (saved_offsets.sections == NULL) if (saved_offsets.sections == NULL)
{ {
if (data) free (data);
free (data);
_bfd_generic_link_hash_table_free (abfd); _bfd_generic_link_hash_table_free (abfd);
abfd->link.next = link_next; abfd->link.next = link_next;
return NULL; return NULL;
@ -267,7 +266,7 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
outbuf, outbuf,
0, 0,
symbol_table); symbol_table);
if (contents == NULL && data != NULL) if (contents == NULL)
free (data); free (data);
bfd_map_over_sections (abfd, simple_restore_output_info, &saved_offsets); bfd_map_over_sections (abfd, simple_restore_output_info, &saved_offsets);

View File

@ -2369,20 +2369,13 @@ setup_sections (bfd *abfd,
for (i = 0; i < total_subspaces; i++) for (i = 0; i < total_subspaces; i++)
subspace_sections[i]->target_index = i; subspace_sections[i]->target_index = i;
if (space_strings != NULL) free (space_strings);
free (space_strings); free (subspace_sections);
if (subspace_sections != NULL)
free (subspace_sections);
return TRUE; return TRUE;
error_return: error_return:
if (space_strings != NULL) free (space_strings);
free (space_strings); free (subspace_sections);
if (subspace_sections != NULL)
free (subspace_sections);
return FALSE; return FALSE;
} }
@ -4528,12 +4521,11 @@ som_build_and_write_symbol_table (bfd *abfd)
if (bfd_bwrite ((void *) som_symtab, symtab_size, abfd) != symtab_size) if (bfd_bwrite ((void *) som_symtab, symtab_size, abfd) != symtab_size)
goto error_return; goto error_return;
if (som_symtab != NULL) free (som_symtab);
free (som_symtab);
return TRUE; return TRUE;
error_return: error_return:
if (som_symtab != NULL) free (som_symtab);
free (som_symtab);
return FALSE; return FALSE;
} }
@ -4827,15 +4819,12 @@ som_slurp_symbol_table (bfd *abfd)
/* Save our results and return success. */ /* Save our results and return success. */
obj_som_symtab (abfd) = symbase; obj_som_symtab (abfd) = symbase;
successful_return: successful_return:
if (buf != NULL) free (buf);
free (buf);
return (TRUE); return (TRUE);
error_return: error_return:
if (symbase != NULL) free (symbase);
free (symbase); free (buf);
if (buf != NULL)
free (buf);
return FALSE; return FALSE;
} }
@ -5230,8 +5219,7 @@ som_set_reloc_info (unsigned char *fixup,
if (!bfd_malloc_and_get_section (section->owner, section, if (!bfd_malloc_and_get_section (section->owner, section,
&contents)) &contents))
{ {
if (contents != NULL) free (contents);
free (contents);
return (unsigned) -1; return (unsigned) -1;
} }
section->contents = contents; section->contents = contents;
@ -5977,13 +5965,11 @@ som_bfd_count_ar_symbols (bfd *abfd,
(*count)++; (*count)++;
} }
} }
if (hash_table != NULL) free (hash_table);
free (hash_table);
return TRUE; return TRUE;
error_return: error_return:
if (hash_table != NULL) free (hash_table);
free (hash_table);
return FALSE; return FALSE;
} }
@ -6152,17 +6138,13 @@ som_bfd_fill_in_ar_symbols (bfd *abfd,
} }
/* If we haven't died by now, then we successfully read the entire /* If we haven't died by now, then we successfully read the entire
archive symbol table. */ archive symbol table. */
if (hash_table != NULL) free (hash_table);
free (hash_table); free (som_dict);
if (som_dict != NULL)
free (som_dict);
return TRUE; return TRUE;
error_return: error_return:
if (hash_table != NULL) free (hash_table);
free (hash_table); free (som_dict);
if (som_dict != NULL)
free (som_dict);
return FALSE; return FALSE;
} }
@ -6611,29 +6593,19 @@ som_bfd_ar_write_symbol_stuff (bfd *abfd,
if (bfd_bwrite ((void *) strings, amt, abfd) != amt) if (bfd_bwrite ((void *) strings, amt, abfd) != amt)
goto error_return; goto error_return;
if (hash_table != NULL) free (hash_table);
free (hash_table); free (som_dict);
if (som_dict != NULL) free (last_hash_entry);
free (som_dict); free (lst_syms);
if (last_hash_entry != NULL) free (strings);
free (last_hash_entry);
if (lst_syms != NULL)
free (lst_syms);
if (strings != NULL)
free (strings);
return TRUE; return TRUE;
error_return: error_return:
if (hash_table != NULL) free (hash_table);
free (hash_table); free (som_dict);
if (som_dict != NULL) free (last_hash_entry);
free (som_dict); free (lst_syms);
if (last_hash_entry != NULL) free (strings);
free (last_hash_entry);
if (lst_syms != NULL)
free (lst_syms);
if (strings != NULL)
free (strings);
return FALSE; return FALSE;
} }
@ -6785,7 +6757,7 @@ som_bfd_free_cached_info (bfd *abfd)
{ {
asection *o; asection *o;
#define FREE(x) if (x != NULL) { free (x); x = NULL; } #define FREE(x) do { free (x); x = NULL; } while (0)
/* Free the native string and symbol tables. */ /* Free the native string and symbol tables. */
FREE (obj_som_symtab (abfd)); FREE (obj_som_symtab (abfd));
FREE (obj_som_stringtab (abfd)); FREE (obj_som_stringtab (abfd));

View File

@ -493,8 +493,7 @@ srec_scan (bfd *abfd)
if (bytes * 2 > bufsize) if (bytes * 2 > bufsize)
{ {
if (buf != NULL) free (buf);
free (buf);
buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2); buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2);
if (buf == NULL) if (buf == NULL)
goto error_return; goto error_return;
@ -618,9 +617,7 @@ srec_scan (bfd *abfd)
goto error_return; goto error_return;
} }
if (buf != NULL) free (buf);
free (buf);
return TRUE; return TRUE;
} }
} }
@ -631,16 +628,12 @@ srec_scan (bfd *abfd)
if (error) if (error)
goto error_return; goto error_return;
if (buf != NULL) free (buf);
free (buf);
return TRUE; return TRUE;
error_return: error_return:
if (symbuf != NULL) free (symbuf);
free (symbuf); free (buf);
if (buf != NULL)
free (buf);
return FALSE; return FALSE;
} }
@ -751,8 +744,7 @@ srec_read_section (bfd *abfd, asection *section, bfd_byte *contents)
if (bytes * 2 > bufsize) if (bytes * 2 > bufsize)
{ {
if (buf != NULL) free (buf);
free (buf);
buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2); buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2);
if (buf == NULL) if (buf == NULL)
goto error_return; goto error_return;
@ -768,8 +760,7 @@ srec_read_section (bfd *abfd, asection *section, bfd_byte *contents)
{ {
default: default:
BFD_ASSERT (sofar == section->size); BFD_ASSERT (sofar == section->size);
if (buf != NULL) free (buf);
free (buf);
return TRUE; return TRUE;
case '3': case '3':
@ -793,8 +784,7 @@ srec_read_section (bfd *abfd, asection *section, bfd_byte *contents)
{ {
/* We've come to the end of this section. */ /* We've come to the end of this section. */
BFD_ASSERT (sofar == section->size); BFD_ASSERT (sofar == section->size);
if (buf != NULL) free (buf);
free (buf);
return TRUE; return TRUE;
} }
@ -817,14 +807,11 @@ srec_read_section (bfd *abfd, asection *section, bfd_byte *contents)
BFD_ASSERT (sofar == section->size); BFD_ASSERT (sofar == section->size);
if (buf != NULL) free (buf);
free (buf);
return TRUE; return TRUE;
error_return: error_return:
if (buf != NULL) free (buf);
free (buf);
return FALSE; return FALSE;
} }

View File

@ -494,10 +494,8 @@ _bfd_link_section_stabs (bfd *abfd,
return TRUE; return TRUE;
error_return: error_return:
if (stabbuf != NULL) free (stabbuf);
free (stabbuf); free (stabstrbuf);
if (stabstrbuf != NULL)
free (stabstrbuf);
return FALSE; return FALSE;
} }
@ -648,8 +646,7 @@ _bfd_discard_section_stabs (bfd *abfd,
return skip > 0; return skip > 0;
error_return: error_return:
if (stabbuf != NULL) free (stabbuf);
free (stabbuf);
return FALSE; return FALSE;
} }

View File

@ -830,8 +830,7 @@ _bfd_generic_read_minisymbols (bfd *abfd,
error_return: error_return:
bfd_set_error (bfd_error_no_symbols); bfd_set_error (bfd_error_no_symbols);
if (syms != NULL) free (syms);
free (syms);
return -1; return -1;
} }
@ -1054,8 +1053,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
symbols); symbols);
if (reloc_count < 0) if (reloc_count < 0)
{ {
if (reloc_vector != NULL) free (reloc_vector);
free (reloc_vector);
return FALSE; return FALSE;
} }
if (reloc_count > 0) if (reloc_count > 0)
@ -1086,8 +1084,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
_bfd_error_handler _bfd_error_handler
(_("unsupported .stab relocation")); (_("unsupported .stab relocation"));
bfd_set_error (bfd_error_invalid_operation); bfd_set_error (bfd_error_invalid_operation);
if (reloc_vector != NULL) free (reloc_vector);
free (reloc_vector);
return FALSE; return FALSE;
} }
@ -1099,8 +1096,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
} }
} }
if (reloc_vector != NULL) free (reloc_vector);
free (reloc_vector);
/* First time through this function, build a table matching /* First time through this function, build a table matching
function VM addresses to stabs, then sort based on starting function VM addresses to stabs, then sort based on starting

View File

@ -1692,8 +1692,7 @@ bfd_get_target_info (const char *target_name, bfd *abfd,
_bfd_find_arch_match (tname, arches, def_target_arch); _bfd_find_arch_match (tname, arches, def_target_arch);
} }
if (arches) free (arches);
free (arches);
} }
return target_vec; return target_vec;
} }

View File

@ -2045,8 +2045,7 @@ _bfd_vms_lib_build_map (unsigned int nbr_modules,
{ {
if (storage > syms_max) if (storage > syms_max)
{ {
if (syms_max > 0) free (syms);
free (syms);
syms_max = storage; syms_max = storage;
syms = (asymbol **) bfd_malloc (syms_max); syms = (asymbol **) bfd_malloc (syms_max);
if (syms == NULL) if (syms == NULL)
@ -2097,10 +2096,8 @@ _bfd_vms_lib_build_map (unsigned int nbr_modules,
return TRUE; return TRUE;
error_return: error_return:
if (syms_max > 0) free (syms);
free (syms); free (map);
if (map != NULL)
free (map);
return FALSE; return FALSE;
} }

View File

@ -227,8 +227,7 @@ xcoff_get_section_contents (bfd *abfd, asection *sec)
if (! bfd_malloc_and_get_section (abfd, sec, &contents)) if (! bfd_malloc_and_get_section (abfd, sec, &contents))
{ {
if (contents != NULL) free (contents);
free (contents);
return FALSE; return FALSE;
} }
coff_section_data (abfd, sec)->contents = contents; coff_section_data (abfd, sec)->contents = contents;
@ -2179,7 +2178,6 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
/* If we are not keeping memory, free the reloc information. */ /* If we are not keeping memory, free the reloc information. */
if (! info->keep_memory if (! info->keep_memory
&& coff_section_data (abfd, o) != NULL && coff_section_data (abfd, o) != NULL
&& coff_section_data (abfd, o)->relocs != NULL
&& ! coff_section_data (abfd, o)->keep_relocs) && ! coff_section_data (abfd, o)->keep_relocs)
{ {
free (coff_section_data (abfd, o)->relocs); free (coff_section_data (abfd, o)->relocs);
@ -2189,11 +2187,8 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
/* Free up the line numbers. FIXME: We could cache these /* Free up the line numbers. FIXME: We could cache these
somewhere for the final link, to avoid reading them again. */ somewhere for the final link, to avoid reading them again. */
if (reloc_info[o->target_index].linenos != NULL) free (reloc_info[o->target_index].linenos);
{ reloc_info[o->target_index].linenos = NULL;
free (reloc_info[o->target_index].linenos);
reloc_info[o->target_index].linenos = NULL;
}
} }
free (reloc_info); free (reloc_info);
@ -2207,10 +2202,8 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
{ {
for (o = abfd->sections; o != NULL; o = o->next) for (o = abfd->sections; o != NULL; o = o->next)
{ {
if (reloc_info[o->target_index].csects != NULL) free (reloc_info[o->target_index].csects);
free (reloc_info[o->target_index].csects); free (reloc_info[o->target_index].linenos);
if (reloc_info[o->target_index].linenos != NULL)
free (reloc_info[o->target_index].linenos);
} }
free (reloc_info); free (reloc_info);
} }
@ -2985,7 +2978,6 @@ xcoff_mark (struct bfd_link_info *info, asection *sec)
if (! info->keep_memory if (! info->keep_memory
&& coff_section_data (sec->owner, sec) != NULL && coff_section_data (sec->owner, sec) != NULL
&& coff_section_data (sec->owner, sec)->relocs != NULL
&& ! coff_section_data (sec->owner, sec)->keep_relocs) && ! coff_section_data (sec->owner, sec)->keep_relocs)
{ {
free (coff_section_data (sec->owner, sec)->relocs); free (coff_section_data (sec->owner, sec)->relocs);
@ -3971,10 +3963,8 @@ bfd_xcoff_size_dynamic_sections (bfd *output_bfd,
return TRUE; return TRUE;
error_return: error_return:
if (ldinfo.strings != NULL) free (ldinfo.strings);
free (ldinfo.strings); free (debug_contents);
if (debug_contents != NULL)
free (debug_contents);
return FALSE; return FALSE;
} }
@ -6207,31 +6197,16 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
} }
/* Free up the buffers used by xcoff_link_input_bfd. */ /* Free up the buffers used by xcoff_link_input_bfd. */
if (flinfo.internal_syms != NULL) free (flinfo.internal_syms);
{ flinfo.internal_syms = NULL;
free (flinfo.internal_syms); free (flinfo.sym_indices);
flinfo.internal_syms = NULL; flinfo.sym_indices = NULL;
} free (flinfo.linenos);
if (flinfo.sym_indices != NULL) flinfo.linenos = NULL;
{ free (flinfo.contents);
free (flinfo.sym_indices); flinfo.contents = NULL;
flinfo.sym_indices = NULL; free (flinfo.external_relocs);
} flinfo.external_relocs = NULL;
if (flinfo.linenos != NULL)
{
free (flinfo.linenos);
flinfo.linenos = NULL;
}
if (flinfo.contents != NULL)
{
free (flinfo.contents);
flinfo.contents = NULL;
}
if (flinfo.external_relocs != NULL)
{
free (flinfo.external_relocs);
flinfo.external_relocs = NULL;
}
/* The value of the last C_FILE symbol is supposed to be -1. Write /* The value of the last C_FILE symbol is supposed to be -1. Write
it out again. */ it out again. */
@ -6250,11 +6225,8 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
input files. */ input files. */
bfd_hash_traverse (&info->hash->table, xcoff_write_global_symbol, &flinfo); bfd_hash_traverse (&info->hash->table, xcoff_write_global_symbol, &flinfo);
if (flinfo.outsyms != NULL) free (flinfo.outsyms);
{ flinfo.outsyms = NULL;
free (flinfo.outsyms);
flinfo.outsyms = NULL;
}
/* Now that we have written out all the global symbols, we know the /* Now that we have written out all the global symbols, we know the
symbol indices to use for relocs against them, and we can finally symbol indices to use for relocs against them, and we can finally
@ -6336,11 +6308,8 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
goto error_return; goto error_return;
} }
if (external_relocs != NULL) free (external_relocs);
{ external_relocs = NULL;
free (external_relocs);
external_relocs = NULL;
}
/* Free up the section information. */ /* Free up the section information. */
if (flinfo.section_info != NULL) if (flinfo.section_info != NULL)
@ -6349,10 +6318,8 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
for (i = 0; i < abfd->section_count; i++) for (i = 0; i < abfd->section_count; i++)
{ {
if (flinfo.section_info[i].relocs != NULL) free (flinfo.section_info[i].relocs);
free (flinfo.section_info[i].relocs); free (flinfo.section_info[i].rel_hashes);
if (flinfo.section_info[i].rel_hashes != NULL)
free (flinfo.section_info[i].rel_hashes);
} }
free (flinfo.section_info); free (flinfo.section_info);
flinfo.section_info = NULL; flinfo.section_info = NULL;
@ -6437,27 +6404,18 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
for (i = 0; i < abfd->section_count; i++) for (i = 0; i < abfd->section_count; i++)
{ {
if (flinfo.section_info[i].relocs != NULL) free (flinfo.section_info[i].relocs);
free (flinfo.section_info[i].relocs); free (flinfo.section_info[i].rel_hashes);
if (flinfo.section_info[i].rel_hashes != NULL)
free (flinfo.section_info[i].rel_hashes);
} }
free (flinfo.section_info); free (flinfo.section_info);
} }
if (flinfo.internal_syms != NULL) free (flinfo.internal_syms);
free (flinfo.internal_syms); free (flinfo.sym_indices);
if (flinfo.sym_indices != NULL) free (flinfo.outsyms);
free (flinfo.sym_indices); free (flinfo.linenos);
if (flinfo.outsyms != NULL) free (flinfo.contents);
free (flinfo.outsyms); free (flinfo.external_relocs);
if (flinfo.linenos != NULL) free (external_relocs);
free (flinfo.linenos);
if (flinfo.contents != NULL)
free (flinfo.contents);
if (flinfo.external_relocs != NULL)
free (flinfo.external_relocs);
if (external_relocs != NULL)
free (external_relocs);
return FALSE; return FALSE;
} }

View File

@ -340,43 +340,26 @@ xtensa_isa_free (xtensa_isa isa)
the memory allocated by xtensa_isa_init and restore the xtensa_isa the memory allocated by xtensa_isa_init and restore the xtensa_isa
structure to its initial state. */ structure to its initial state. */
if (intisa->opname_lookup_table) free (intisa->opname_lookup_table);
{ intisa->opname_lookup_table = 0;
free (intisa->opname_lookup_table);
intisa->opname_lookup_table = 0;
}
if (intisa->state_lookup_table) free (intisa->state_lookup_table);
{ intisa->state_lookup_table = 0;
free (intisa->state_lookup_table);
intisa->state_lookup_table = 0; free (intisa->sysreg_lookup_table);
} intisa->sysreg_lookup_table = 0;
if (intisa->sysreg_lookup_table)
{
free (intisa->sysreg_lookup_table);
intisa->sysreg_lookup_table = 0;
}
for (n = 0; n < 2; n++) for (n = 0; n < 2; n++)
{ {
if (intisa->sysreg_table[n]) free (intisa->sysreg_table[n]);
{ intisa->sysreg_table[n] = 0;
free (intisa->sysreg_table[n]);
intisa->sysreg_table[n] = 0;
}
} }
if (intisa->interface_lookup_table) free (intisa->interface_lookup_table);
{ intisa->interface_lookup_table = 0;
free (intisa->interface_lookup_table);
intisa->interface_lookup_table = 0;
}
if (intisa->funcUnit_lookup_table) free (intisa->funcUnit_lookup_table);
{ intisa->funcUnit_lookup_table = 0;
free (intisa->funcUnit_lookup_table);
intisa->funcUnit_lookup_table = 0;
}
} }