forked from Imagelibrary/binutils-gdb
Replace uses of asprintf with xasprintf
xasprintf has a nicer interface and behaves like xmalloc as far as memory is concerned, ie. no need to check a return status and the program exits with an error on OOM. binutils/ * dwarf.c (load_debug_sup_file): Replace asprintf with xasprintf. * nm.c (get_elf_symbol_type, get_coff_symbol_type): Likewise. * objdump.c (dump_ctf_indent_lines): Likewise. * readelf.c (display_lto_symtab, dump_ctf_indent_lines): Likewise. * windres.c (main): Likewise. * configure.ac: Remove asprintf from AC_CHECK_DECLS. * config.in: Regenerate. * configure: Regenerate. gas/ * config/tc-kvx.c (kvx_emit_single_noop): Simplify. * config/tc-riscv.c (md_assemblef): Replace asprintf with xasprintf. * read.c (s_nop, do_s_func): Likewise. * stabs.c (stabs_generate_asm_func): Likewise. (stabs_generate_asm_endfunc): Likewise. * configure.ac: Remove asprintf from AC_CHECK_DECLS. * config.in: Regenerate. * configure: Regenerate. ld/ * ldlang.c (lang_leave_overlay_section): Replace xmalloc+sprintf with xasprintf. Localise vars. * lexsup.c (parse_args): Replace asprintf with xasprintf. * pe-dll.c (make_head, make_tail, make_one): Likewise. (make_singleton_name_thunk, make_import_fixup_entry): Likewise. (make_runtime_pseudo_reloc): Likewise. (pe_create_runtime_relocator_reference): Likewise. * configure.ac: Remove asprintf from AC_CHECK_DECLS. * config.in: Regenerate. * configure: Regenerate.
This commit is contained in:
@@ -12318,34 +12318,14 @@ load_debug_sup_file (const char * main_filename, void * file)
|
||||
}
|
||||
|
||||
if (filename[0] != '/' && strchr (main_filename, '/'))
|
||||
{
|
||||
char * new_name;
|
||||
int new_len;
|
||||
|
||||
new_len = asprintf (& new_name, "%.*s/%s",
|
||||
filename = xasprintf ("%.*s/%s",
|
||||
(int) (strrchr (main_filename, '/') - main_filename),
|
||||
main_filename,
|
||||
filename);
|
||||
if (new_len < 3)
|
||||
{
|
||||
warn (_("unable to construct path for supplementary debug file\n"));
|
||||
if (new_len > -1)
|
||||
free (new_name);
|
||||
return;
|
||||
}
|
||||
filename = new_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* PR 27796: Make sure that we pass a filename that can be free'd to
|
||||
add_separate_debug_file(). */
|
||||
filename = strdup (filename);
|
||||
if (filename == NULL)
|
||||
{
|
||||
warn (_("out of memory constructing filename for .debug_sup link\n"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* PR 27796: Make sure that we pass a filename that can be free'd to
|
||||
add_separate_debug_file(). */
|
||||
filename = xstrdup (filename);
|
||||
|
||||
void * handle = open_debug_file (filename);
|
||||
if (handle == NULL)
|
||||
|
||||
Reference in New Issue
Block a user