aboutsummaryrefslogtreecommitdiff
path: root/bfd/coff-alpha.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2009-10-16 07:14:43 +0000
committerAlan Modra <amodra@gmail.com>2009-10-16 07:14:43 +0000
commit493152cb4f287f9de3f03743349e911df9448e60 (patch)
tree73825fdd6b8ba7e0238b5957c702b55308e4ffc6 /bfd/coff-alpha.c
parent12edd763cc3b83a257eb3173caca075f027e9afa (diff)
downloadgdb-493152cb4f287f9de3f03743349e911df9448e60.zip
gdb-493152cb4f287f9de3f03743349e911df9448e60.tar.gz
gdb-493152cb4f287f9de3f03743349e911df9448e60.tar.bz2
PR binutils/10785
* coff-alpha.c (alpha_ecoff_get_elt_at_filepos): Don't bfd_alloc bim and bim->buffer. bfd_malloc instead. * peicode.h (pe_ILF_build_a_bfd): Similarly. (ILF_DATA_SIZE): Don't include bim. * opncls.c (bfd_close): Test bim->buffer non-NULL before freeing.
Diffstat (limited to 'bfd/coff-alpha.c')
-rw-r--r--bfd/coff-alpha.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c
index cd69043..0d67264 100644
--- a/bfd/coff-alpha.c
+++ b/bfd/coff-alpha.c
@@ -2120,6 +2120,7 @@ alpha_ecoff_get_elt_at_filepos (archive, filepos)
bfd_byte *buf, *p;
struct bfd_in_memory *bim;
+ buf = NULL;
nbfd = _bfd_get_elt_at_filepos (archive, filepos);
if (nbfd == NULL)
goto error_return;
@@ -2151,16 +2152,14 @@ alpha_ecoff_get_elt_at_filepos (archive, filepos)
goto error_return;
size = H_GET_64 (nbfd, ab);
- if (size == 0)
- buf = NULL;
- else
+ if (size != 0)
{
bfd_size_type left;
bfd_byte dict[4096];
unsigned int h;
bfd_byte b;
- buf = (bfd_byte *) bfd_alloc (nbfd, size);
+ buf = (bfd_byte *) bfd_malloc (size);
if (buf == NULL)
goto error_return;
p = buf;
@@ -2214,7 +2213,7 @@ alpha_ecoff_get_elt_at_filepos (archive, filepos)
/* Now the uncompressed file contents are in buf. */
bim = ((struct bfd_in_memory *)
- bfd_alloc (nbfd, (bfd_size_type) sizeof (struct bfd_in_memory)));
+ bfd_malloc ((bfd_size_type) sizeof (struct bfd_in_memory)));
if (bim == NULL)
goto error_return;
bim->size = size;
@@ -2230,6 +2229,8 @@ alpha_ecoff_get_elt_at_filepos (archive, filepos)
return nbfd;
error_return:
+ if (buf != NULL)
+ free (buf);
if (nbfd != NULL)
bfd_close (nbfd);
return NULL;