pe_ILF_vars;
#endif /* COFF_IMAGE_WITH_PE */
-const bfd_target *coff_real_object_p
+bfd_cleanup coff_real_object_p
(bfd *, unsigned, struct internal_filehdr *, struct internal_aouthdr *);
\f
#ifndef NO_COFF_RELOCS
return TRUE;
error_return:
- if (vars.bim->buffer != NULL)
- free (vars.bim->buffer);
+ free (vars.bim->buffer);
free (vars.bim);
return FALSE;
}
/* We have detected a Image Library Format archive element.
Decode the element and return the appropriate target. */
-static const bfd_target *
+static bfd_cleanup
pe_ILF_object_p (bfd * abfd)
{
bfd_byte buffer[14];
/* ptr += 2; */
/* Now read in the two strings that follow. */
- ptr = (bfd_byte *) bfd_alloc (abfd, size);
+ ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size);
if (ptr == NULL)
return NULL;
- if (bfd_bread (ptr, size, abfd) != size)
- {
- bfd_release (abfd, ptr);
- return NULL;
- }
-
symbol_name = (char *) ptr;
/* See PR 20905 for an example of where the strnlen is necessary. */
source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1;
return NULL;
}
- return abfd->xvec;
+ return _bfd_no_cleanup;
}
static void
/* Read the whole section. */
if (!bfd_malloc_and_get_section (abfd, section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return;
}
free (data);
}
-static const bfd_target *
+static bfd_cleanup
pe_bfd_object_p (bfd * abfd)
{
bfd_byte buffer[6];
struct external_PEI_IMAGE_hdr image_hdr;
struct internal_filehdr internal_f;
struct internal_aouthdr internal_a;
- file_ptr opt_hdr_size;
+ bfd_size_type opt_hdr_size;
file_ptr offset;
- const bfd_target *result;
+ bfd_cleanup result;
/* Detect if this a Microsoft Import Library Format element. */
/* First read the beginning of the header. */
if (amt < sizeof (PEAOUTHDR))
amt = sizeof (PEAOUTHDR);
- opthdr = bfd_zalloc (abfd, amt);
+ opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size);
if (opthdr == NULL)
return NULL;
- if (bfd_bread (opthdr, opt_hdr_size, abfd)
- != (bfd_size_type) opt_hdr_size)
- return NULL;
+ if (amt > opt_hdr_size)
+ memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size);
bfd_set_error (bfd_error_no_error);
bfd_coff_swap_aouthdr_in (abfd, opthdr, & internal_a);