summaryrefslogtreecommitdiff
path: root/bfd/bfdio.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2008-02-20 17:42:36 +0000
committerNick Clifton <nickc@redhat.com>2008-02-20 17:42:36 +0000
commit96d3cffec0d9bcc2324384d27413aee3eb37317b (patch)
treed1a5bcecf4b4c4251118947034c20157f7bb2946 /bfd/bfdio.c
parent0190eb9e40e11e9f4bf91e203f3af961babf2635 (diff)
downloadbinutils-redhat-96d3cffec0d9bcc2324384d27413aee3eb37317b.tar.gz
PR 868
* libbfd.c (bfd_realloc_or_free): New function. Performs like bfd_realloc, but if the (re)allocation fails, the pointer is freed. * libbfd-in.h: Prototype. * libbfd.h: Regenerate. * bfdio.c (bfd_bwrite): Use the new function. (bfd_seek): Likewise. * bfdwin.c:(bfd_get_file_window): Likewise. * elf-strtab.c (_bfd_elf_strtab_add): Likewise. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-xtensa.c (vsprintf_msg): Likewise. * mach-o.c (bfd_mach_o_core_fetch_environment): Likewise. * stabs.c (_bfd_link_seciton_stabs): Likewise. * vms-misc.c (_bfd_vms_get_record): Likewise. * vms-tir.c (check_section): Likewise. * vms.c (vms_new_section_hook): Likewise. * elf32-arm.c (elf32_arm_section_map_add): Check that the allocation of sec_data->map succeeded before using it. * elflink.c (elf_link_output_sym): Do not overwrite finfo-> symshndxbuf until it is known that the reallocation succeeded.
Diffstat (limited to 'bfd/bfdio.c')
-rw-r--r--bfd/bfdio.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 080cd947f8..d8aa1de999 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -1,7 +1,7 @@
/* Low-level I/O routines for BFDs.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
Written by Cygnus Support.
@@ -174,8 +174,8 @@ bfd_bwrite (const void *ptr, bfd_size_type size, bfd *abfd)
newsize = (bim->size + 127) & ~(bfd_size_type) 127;
if (newsize > oldsize)
{
- bim->buffer = bfd_realloc (bim->buffer, newsize);
- if (bim->buffer == 0)
+ bim->buffer = bfd_realloc_or_free (bim->buffer, newsize);
+ if (bim->buffer == NULL)
{
bim->size = 0;
return 0;
@@ -298,8 +298,8 @@ bfd_seek (bfd *abfd, file_ptr position, int direction)
newsize = (bim->size + 127) & ~(bfd_size_type) 127;
if (newsize > oldsize)
{
- bim->buffer = bfd_realloc (bim->buffer, newsize);
- if (bim->buffer == 0)
+ bim->buffer = bfd_realloc_or_free (bim->buffer, newsize);
+ if (bim->buffer == NULL)
{
bim->size = 0;
return -1;