Replace "if (x) free (x)" with "free (x)", binutils
* addr2line.c: Replace "if (x) free (x)" with "free (x)" throughout. * dlltool.c: Likewise. * elfcomm.c: Likewise. * rddbg.c: Likewise. * readelf.c: Likewise. * stabs.c: Likewise. * windmc.c: Likewise. * windres.c: Likewise. * wrstabs.c: Likewise.
This commit is contained in:
parent
c95949892f
commit
9db70fc365
@ -1,3 +1,15 @@
|
||||
2020-05-21 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* addr2line.c: Replace "if (x) free (x)" with "free (x)" throughout.
|
||||
* dlltool.c: Likewise.
|
||||
* elfcomm.c: Likewise.
|
||||
* rddbg.c: Likewise.
|
||||
* readelf.c: Likewise.
|
||||
* stabs.c: Likewise.
|
||||
* windmc.c: Likewise.
|
||||
* windres.c: Likewise.
|
||||
* wrstabs.c: Likewise.
|
||||
|
||||
2020-05-21 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* readelf.c (get_num_dynamic_syms): Bounds check mipsxlat array
|
||||
|
@ -314,7 +314,6 @@ translate_addresses (bfd *abfd, asection *section)
|
||||
else
|
||||
printf ("\n");
|
||||
|
||||
if (alloc != NULL)
|
||||
free (alloc);
|
||||
}
|
||||
|
||||
@ -410,11 +409,8 @@ process_file (const char *file_name, const char *section_name,
|
||||
|
||||
translate_addresses (abfd, section);
|
||||
|
||||
if (syms != NULL)
|
||||
{
|
||||
free (syms);
|
||||
syms = NULL;
|
||||
}
|
||||
|
||||
bfd_close (abfd);
|
||||
|
||||
|
@ -1253,7 +1253,6 @@ def_import (const char *app_name, const char *module, const char *dllext,
|
||||
|
||||
append_import (application_name, module, ord_val, its_name);
|
||||
|
||||
if (buf)
|
||||
free (buf);
|
||||
}
|
||||
|
||||
@ -1335,7 +1334,7 @@ run (const char *what, char *args)
|
||||
|
||||
pid = pexecute (argv[0], (char * const *) argv, program_name, temp_base,
|
||||
&errmsg_fmt, &errmsg_arg, PEXECUTE_ONE | PEXECUTE_SEARCH);
|
||||
free(argv);
|
||||
free (argv);
|
||||
|
||||
if (pid == -1)
|
||||
{
|
||||
@ -3388,15 +3387,8 @@ dll_name_list_free_contents (dll_name_list_node_type * entry)
|
||||
if (entry)
|
||||
{
|
||||
if (entry->next)
|
||||
{
|
||||
dll_name_list_free_contents (entry->next);
|
||||
entry->next = NULL;
|
||||
}
|
||||
if (entry->dllname)
|
||||
{
|
||||
free (entry->dllname);
|
||||
entry->dllname = NULL;
|
||||
}
|
||||
free (entry);
|
||||
}
|
||||
}
|
||||
|
@ -744,13 +744,9 @@ setup_nested_archive (struct archive_info *nested_arch,
|
||||
void
|
||||
release_archive (struct archive_info * arch)
|
||||
{
|
||||
if (arch->file_name != NULL)
|
||||
free (arch->file_name);
|
||||
if (arch->index_array != NULL)
|
||||
free (arch->index_array);
|
||||
if (arch->sym_table != NULL)
|
||||
free (arch->sym_table);
|
||||
if (arch->longnames != NULL)
|
||||
free (arch->longnames);
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,6 @@ read_symbol_stabs_debugging_info (bfd *abfd, asymbol **syms, long symcount,
|
||||
sc[strlen (sc) - 1] = '\0';
|
||||
n = concat (sc, bfd_asymbol_name (*ps), (const char *) NULL);
|
||||
free (sc);
|
||||
if (f != NULL)
|
||||
free (f);
|
||||
f = n;
|
||||
s = n;
|
||||
@ -372,7 +371,6 @@ static int saved_stabs_index;
|
||||
static void
|
||||
save_stab (int type, int desc, bfd_vma value, const char *string)
|
||||
{
|
||||
if (saved_stabs[saved_stabs_index].string != NULL)
|
||||
free (saved_stabs[saved_stabs_index].string);
|
||||
saved_stabs[saved_stabs_index].type = type;
|
||||
saved_stabs[saved_stabs_index].desc = desc;
|
||||
@ -427,13 +425,10 @@ free_saved_stabs (void)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SAVE_STABS_COUNT; i++)
|
||||
{
|
||||
if (saved_stabs[i].string != NULL)
|
||||
{
|
||||
free (saved_stabs[i].string);
|
||||
saved_stabs[i].string = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
saved_stabs_index = 0;
|
||||
}
|
||||
|
@ -7010,7 +7010,6 @@ process_section_groups (Filedata * filedata)
|
||||
if (symtab_sec != sec)
|
||||
{
|
||||
symtab_sec = sec;
|
||||
if (symtab)
|
||||
free (symtab);
|
||||
symtab = GET_ELF_SYMBOLS (filedata, symtab_sec, & num_syms);
|
||||
}
|
||||
@ -7040,7 +7039,6 @@ process_section_groups (Filedata * filedata)
|
||||
|
||||
group_name = SECTION_NAME (filedata->section_headers + sym->st_shndx);
|
||||
strtab_sec = NULL;
|
||||
if (strtab)
|
||||
free (strtab);
|
||||
strtab = NULL;
|
||||
strtab_size = 0;
|
||||
@ -7051,7 +7049,6 @@ process_section_groups (Filedata * filedata)
|
||||
if (symtab_sec->sh_link >= filedata->file_header.e_shnum)
|
||||
{
|
||||
strtab_sec = NULL;
|
||||
if (strtab)
|
||||
free (strtab);
|
||||
strtab = NULL;
|
||||
strtab_size = 0;
|
||||
@ -7060,7 +7057,6 @@ process_section_groups (Filedata * filedata)
|
||||
!= (sec = filedata->section_headers + symtab_sec->sh_link))
|
||||
{
|
||||
strtab_sec = sec;
|
||||
if (strtab)
|
||||
free (strtab);
|
||||
|
||||
strtab = (char *) get_data (NULL, filedata, strtab_sec->sh_offset,
|
||||
@ -7169,16 +7165,13 @@ process_section_groups (Filedata * filedata)
|
||||
group->root = g;
|
||||
}
|
||||
|
||||
if (start)
|
||||
free (start);
|
||||
|
||||
group++;
|
||||
}
|
||||
}
|
||||
|
||||
if (symtab)
|
||||
free (symtab);
|
||||
if (strtab)
|
||||
free (strtab);
|
||||
return TRUE;
|
||||
}
|
||||
@ -7367,7 +7360,6 @@ process_ia64_vms_dynamic_relocs (Filedata * filedata)
|
||||
}
|
||||
}
|
||||
|
||||
if (strtab != NULL)
|
||||
free (strtab);
|
||||
|
||||
return res;
|
||||
@ -7514,7 +7506,6 @@ process_relocs (Filedata * filedata)
|
||||
symtab, nsyms, strtab, strtablen,
|
||||
is_rela,
|
||||
symsec->sh_type == SHT_DYNSYM);
|
||||
if (strtab)
|
||||
free (strtab);
|
||||
free (symtab);
|
||||
}
|
||||
@ -8041,18 +8032,14 @@ ia64_process_unwind (Filedata * filedata)
|
||||
&& aux.table_len > 0)
|
||||
dump_ia64_unwind (filedata, & aux);
|
||||
|
||||
if (aux.table)
|
||||
free ((char *) aux.table);
|
||||
if (aux.info)
|
||||
free ((char *) aux.info);
|
||||
aux.table = NULL;
|
||||
aux.info = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (aux.symtab)
|
||||
free (aux.symtab);
|
||||
if (aux.strtab)
|
||||
free ((char *) aux.strtab);
|
||||
|
||||
return res;
|
||||
@ -8423,15 +8410,12 @@ hppa_process_unwind (Filedata * filedata)
|
||||
res = FALSE;
|
||||
}
|
||||
|
||||
if (aux.table)
|
||||
free ((char *) aux.table);
|
||||
aux.table = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (aux.symtab)
|
||||
free (aux.symtab);
|
||||
if (aux.strtab)
|
||||
free ((char *) aux.strtab);
|
||||
|
||||
return res;
|
||||
@ -8492,10 +8476,7 @@ arm_print_vma_and_name (Filedata * filedata,
|
||||
static void
|
||||
arm_free_section (struct arm_section *arm_sec)
|
||||
{
|
||||
if (arm_sec->data != NULL)
|
||||
free (arm_sec->data);
|
||||
|
||||
if (arm_sec->rela != NULL)
|
||||
free (arm_sec->rela);
|
||||
}
|
||||
|
||||
@ -9530,9 +9511,7 @@ arm_process_unwind (Filedata * filedata)
|
||||
}
|
||||
}
|
||||
|
||||
if (aux.symtab)
|
||||
free (aux.symtab);
|
||||
if (aux.strtab)
|
||||
free ((char *) aux.strtab);
|
||||
|
||||
return res;
|
||||
@ -10061,17 +10040,11 @@ get_num_dynamic_syms (Filedata * filedata)
|
||||
}
|
||||
no_hash:
|
||||
if (num_of_syms == 0)
|
||||
{
|
||||
if (filedata->buckets)
|
||||
{
|
||||
free (filedata->buckets);
|
||||
filedata->buckets = NULL;
|
||||
}
|
||||
if (filedata->chains)
|
||||
{
|
||||
free (filedata->chains);
|
||||
filedata->chains = NULL;
|
||||
}
|
||||
filedata->nbuckets = 0;
|
||||
}
|
||||
}
|
||||
@ -10229,21 +10202,12 @@ get_num_dynamic_syms (Filedata * filedata)
|
||||
if (num_of_syms == 0)
|
||||
{
|
||||
no_gnu_hash:
|
||||
if (filedata->mipsxlat)
|
||||
{
|
||||
free (filedata->mipsxlat);
|
||||
filedata->mipsxlat = NULL;
|
||||
}
|
||||
if (filedata->gnuchains)
|
||||
{
|
||||
free (filedata->gnuchains);
|
||||
filedata->gnuchains = NULL;
|
||||
}
|
||||
if (filedata->gnubuckets)
|
||||
{
|
||||
free (filedata->gnubuckets);
|
||||
filedata->gnubuckets = NULL;
|
||||
}
|
||||
filedata->ngnubuckets = 0;
|
||||
filedata->ngnuchains = 0;
|
||||
}
|
||||
@ -14654,12 +14618,9 @@ free_debug_section (enum dwarf_section_display_enum debug)
|
||||
section->address = 0;
|
||||
section->size = 0;
|
||||
|
||||
if (section->reloc_info != NULL)
|
||||
{
|
||||
free (section->reloc_info);
|
||||
section->reloc_info = NULL;
|
||||
section->num_relocs = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static bfd_boolean
|
||||
@ -16763,7 +16724,6 @@ process_mips_specific (Filedata * filedata)
|
||||
}
|
||||
|
||||
sgot_print_fail:
|
||||
if (data)
|
||||
free (data);
|
||||
}
|
||||
return res;
|
||||
@ -17396,7 +17356,6 @@ process_mips_specific (Filedata * filedata)
|
||||
}
|
||||
|
||||
got_print_fail:
|
||||
if (data)
|
||||
free (data);
|
||||
}
|
||||
|
||||
@ -17474,7 +17433,6 @@ process_mips_specific (Filedata * filedata)
|
||||
}
|
||||
printf ("\n");
|
||||
|
||||
if (data)
|
||||
free (data);
|
||||
free (rels);
|
||||
}
|
||||
@ -19747,12 +19705,9 @@ process_notes_at (Filedata * filedata,
|
||||
if (! process_note (& inote, filedata))
|
||||
res = FALSE;
|
||||
|
||||
if (temp != NULL)
|
||||
{
|
||||
free (temp);
|
||||
temp = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
free (pnotes);
|
||||
|
||||
@ -20305,38 +20260,23 @@ process_object (Filedata * filedata)
|
||||
filedata->string_table = NULL;
|
||||
filedata->string_table_length = 0;
|
||||
|
||||
if (filedata->dump.dump_sects != NULL)
|
||||
{
|
||||
free (filedata->dump.dump_sects);
|
||||
filedata->dump.dump_sects = NULL;
|
||||
filedata->dump.num_dump_sects = 0;
|
||||
}
|
||||
|
||||
if (filedata->dynamic_strings)
|
||||
{
|
||||
free (filedata->dynamic_strings);
|
||||
filedata->dynamic_strings = NULL;
|
||||
filedata->dynamic_strings_length = 0;
|
||||
}
|
||||
|
||||
if (filedata->dynamic_symbols)
|
||||
{
|
||||
free (filedata->dynamic_symbols);
|
||||
filedata->dynamic_symbols = NULL;
|
||||
filedata->num_dynamic_syms = 0;
|
||||
}
|
||||
|
||||
if (filedata->dynamic_syminfo)
|
||||
{
|
||||
free (filedata->dynamic_syminfo);
|
||||
filedata->dynamic_syminfo = NULL;
|
||||
}
|
||||
|
||||
if (filedata->dynamic_section)
|
||||
{
|
||||
free (filedata->dynamic_section);
|
||||
filedata->dynamic_section = NULL;
|
||||
}
|
||||
|
||||
while (filedata->symtab_shndx_list != NULL)
|
||||
{
|
||||
@ -20345,11 +20285,8 @@ process_object (Filedata * filedata)
|
||||
filedata->symtab_shndx_list = next;
|
||||
}
|
||||
|
||||
if (filedata->section_headers_groups)
|
||||
{
|
||||
free (filedata->section_headers_groups);
|
||||
filedata->section_headers_groups = NULL;
|
||||
}
|
||||
|
||||
if (filedata->section_groups)
|
||||
{
|
||||
@ -20810,7 +20747,6 @@ main (int argc, char ** argv)
|
||||
if (! process_file (argv[optind++]))
|
||||
err = TRUE;
|
||||
|
||||
if (cmdline.dump_sects != NULL)
|
||||
free (cmdline.dump_sects);
|
||||
|
||||
free (dump_ctf_symtab_name);
|
||||
|
@ -2119,7 +2119,6 @@ parse_stab_struct_type (void * dhandle,
|
||||
|| ! parse_stab_tilde_field (dhandle, info, pp, typenums, &vptrbase,
|
||||
&ownvptr, p_end))
|
||||
{
|
||||
if (fields != NULL)
|
||||
free (fields);
|
||||
return DEBUG_TYPE_NULL;
|
||||
}
|
||||
@ -2955,11 +2954,8 @@ parse_stab_members (void * dhandle,
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
if (name != NULL)
|
||||
free (name);
|
||||
if (variants != NULL)
|
||||
free (variants);
|
||||
if (argtypes != NULL)
|
||||
free (argtypes);
|
||||
return FALSE;
|
||||
}
|
||||
@ -3901,7 +3897,6 @@ stab_demangle_argtypes (void *dhandle, struct stab_handle *info,
|
||||
return minfo.args;
|
||||
|
||||
error_return:
|
||||
if (minfo.typestrings != NULL)
|
||||
free (minfo.typestrings);
|
||||
return NULL;
|
||||
}
|
||||
@ -4516,7 +4511,6 @@ stab_demangle_template (struct stab_demangle_info *minfo, const char **pp,
|
||||
if (s3 == NULL || s4 == NULL)
|
||||
{
|
||||
stab_bad_demangle (orig);
|
||||
if (s3 != NULL)
|
||||
free (s3);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1161,11 +1161,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
write_bin ();
|
||||
|
||||
if (mc_nodes_lang)
|
||||
free (mc_nodes_lang);
|
||||
if (mc_severity_codes)
|
||||
free (mc_severity_codes);
|
||||
if (mc_facility_codes)
|
||||
free (mc_facility_codes);
|
||||
|
||||
xexit (0);
|
||||
|
@ -704,7 +704,6 @@ quot (const char *string)
|
||||
if ((buflen < slen * 2 + 2) || ! buf)
|
||||
{
|
||||
buflen = slen * 2 + 2;
|
||||
if (buf)
|
||||
free (buf);
|
||||
buf = (char *) xmalloc (buflen);
|
||||
}
|
||||
|
@ -1224,7 +1224,6 @@ stab_method_type (void *p, bfd_boolean domainp, int argcount,
|
||||
}
|
||||
strcat (buf, ";");
|
||||
|
||||
if (args != NULL)
|
||||
free (args);
|
||||
|
||||
if (! stab_push_string (info, buf, 0, definition, 0))
|
||||
|
Loading…
x
Reference in New Issue
Block a user