aboutsummaryrefslogtreecommitdiff
path: root/bfd/archive.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/archive.c')
-rw-r--r--bfd/archive.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/bfd/archive.c b/bfd/archive.c
index 91127d7..d2a9a65 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -968,16 +968,11 @@ do_slurp_bsd_armap (bfd *abfd)
if (parsed_size < 4)
return FALSE;
- raw_armap = (bfd_byte *) bfd_alloc (abfd, parsed_size);
+ raw_armap = (bfd_byte *) _bfd_alloc_and_read (abfd, parsed_size, parsed_size);
if (raw_armap == NULL)
- return FALSE;
-
- if (bfd_bread (raw_armap, parsed_size, abfd) != parsed_size)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_malformed_archive);
- byebye:
- bfd_release (abfd, raw_armap);
return FALSE;
}
@@ -987,7 +982,8 @@ do_slurp_bsd_armap (bfd *abfd)
{
/* Probably we're using the wrong byte ordering. */
bfd_set_error (bfd_error_wrong_format);
- goto byebye;
+ bfd_release (abfd, raw_armap);
+ return FALSE;
}
rbase = raw_armap + BSD_SYMDEF_COUNT_SIZE;
@@ -997,7 +993,10 @@ do_slurp_bsd_armap (bfd *abfd)
amt = ardata->symdef_count * sizeof (carsym);
ardata->symdefs = (struct carsym *) bfd_alloc (abfd, amt);
if (!ardata->symdefs)
- return FALSE;
+ {
+ bfd_release (abfd, raw_armap);
+ return FALSE;
+ }
for (counter = 0, set = ardata->symdefs;
counter < ardata->symdef_count;
@@ -1081,10 +1080,8 @@ do_slurp_coff_armap (bfd *abfd)
stringbase = ((char *) ardata->symdefs) + carsym_size;
/* Allocate and read in the raw offsets. */
- raw_armap = (int *) bfd_alloc (abfd, ptrsize);
- if (raw_armap == NULL)
- goto release_symdefs;
- if (bfd_bread (raw_armap, ptrsize, abfd) != ptrsize
+ raw_armap = (int *) _bfd_alloc_and_read (abfd, ptrsize, ptrsize);
+ if (raw_armap == NULL
|| (bfd_bread (stringbase, stringsize, abfd) != stringsize))
{
if (bfd_get_error () != bfd_error_system_call)