forked from Imagelibrary/binutils-gdb
PR24955, libbfd terminating program on out of memory
This patch fixes the worst of the cases where libbfd might terminate a program due to calling xstrdup or xmalloc. I've also fixed some error paths that didn't clean up properly. PR 24955 * libbfd-in.h (bfd_strdup): New inline function. * archive.c (_bfd_get_elt_at_filepos): Use bfd_strdup. Close bfd on error. * elfcode.h (_bfd_elf_bfd_from_remote_memory): Use bfd_strdup. * opncls.c (bfd_fopen): Use bfd_strdup. Close fd and stream on error. (bfd_openstreamr): Use bfd_strdup. (bfd_openr_iovec, bfd_openw, bfd_create): Likewise. * plugin.c (try_load_plugin): Use bfd_malloc. * libbfd.h: Regenerate.
This commit is contained in:
@@ -262,7 +262,9 @@ try_load_plugin (const char *pname, bfd *abfd, int *has_plugin_p)
|
||||
}
|
||||
}
|
||||
|
||||
plugin_list_iter = (struct plugin_list_entry *) xmalloc (sizeof *plugin_list_iter);
|
||||
plugin_list_iter = bfd_malloc (sizeof *plugin_list_iter);
|
||||
if (plugin_list_iter == NULL)
|
||||
return 0;
|
||||
plugin_list_iter->handle = plugin_handle;
|
||||
plugin_list_iter->claim_file = NULL;
|
||||
plugin_list_iter->next = plugin_list;
|
||||
|
||||
Reference in New Issue
Block a user