_bfd_xcoff_read_ar_hdr tidy
* coff-rs6000.c (_bfd_xcoff_read_ar_hdr): Put all data in one malloc'd block.
This commit is contained in:
parent
ff69a8949b
commit
05f52dc2e1
2 changed files with 22 additions and 31 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2020-02-27 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* coff-rs6000.c (_bfd_xcoff_read_ar_hdr): Put all data in one
|
||||||
|
malloc'd block.
|
||||||
|
|
||||||
2020-02-27 Alan Modra <amodra@gmail.com>
|
2020-02-27 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* bfd.c (bfd_stat_arch_elt): Use vector of containing archive,
|
* bfd.c (bfd_stat_arch_elt): Use vector of containing archive,
|
||||||
|
|
|
@ -1491,32 +1491,23 @@ _bfd_xcoff_read_ar_hdr (bfd *abfd)
|
||||||
{
|
{
|
||||||
bfd_size_type namlen;
|
bfd_size_type namlen;
|
||||||
struct areltdata *ret;
|
struct areltdata *ret;
|
||||||
bfd_size_type amt = sizeof (struct areltdata);
|
bfd_size_type amt;
|
||||||
|
|
||||||
ret = (struct areltdata *) bfd_zmalloc (amt);
|
|
||||||
if (ret == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (! xcoff_big_format_p (abfd))
|
if (! xcoff_big_format_p (abfd))
|
||||||
{
|
{
|
||||||
struct xcoff_ar_hdr hdr;
|
struct xcoff_ar_hdr hdr;
|
||||||
struct xcoff_ar_hdr *hdrp;
|
struct xcoff_ar_hdr *hdrp;
|
||||||
|
|
||||||
if (bfd_bread (&hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
|
if (bfd_bread (&hdr, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR)
|
||||||
!= SIZEOF_AR_HDR)
|
return NULL;
|
||||||
{
|
|
||||||
free (ret);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
|
GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
|
||||||
amt = SIZEOF_AR_HDR + namlen + 1;
|
amt = sizeof (struct areltdata) + SIZEOF_AR_HDR + namlen + 1;
|
||||||
hdrp = (struct xcoff_ar_hdr *) bfd_alloc (abfd, amt);
|
ret = (struct areltdata *) bfd_malloc (amt);
|
||||||
if (hdrp == NULL)
|
if (ret == NULL)
|
||||||
{
|
return ret;
|
||||||
free (ret);
|
|
||||||
return NULL;
|
hdrp = (struct xcoff_ar_hdr *) (ret + 1);
|
||||||
}
|
|
||||||
memcpy (hdrp, &hdr, SIZEOF_AR_HDR);
|
memcpy (hdrp, &hdr, SIZEOF_AR_HDR);
|
||||||
if (bfd_bread ((char *) hdrp + SIZEOF_AR_HDR, namlen, abfd) != namlen)
|
if (bfd_bread ((char *) hdrp + SIZEOF_AR_HDR, namlen, abfd) != namlen)
|
||||||
{
|
{
|
||||||
|
@ -1534,21 +1525,16 @@ _bfd_xcoff_read_ar_hdr (bfd *abfd)
|
||||||
struct xcoff_ar_hdr_big hdr;
|
struct xcoff_ar_hdr_big hdr;
|
||||||
struct xcoff_ar_hdr_big *hdrp;
|
struct xcoff_ar_hdr_big *hdrp;
|
||||||
|
|
||||||
if (bfd_bread (&hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
|
if (bfd_bread (&hdr, SIZEOF_AR_HDR_BIG, abfd) != SIZEOF_AR_HDR_BIG)
|
||||||
!= SIZEOF_AR_HDR_BIG)
|
return NULL;
|
||||||
{
|
|
||||||
free (ret);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
|
GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
|
||||||
amt = SIZEOF_AR_HDR_BIG + namlen + 1;
|
amt = sizeof (struct areltdata) + SIZEOF_AR_HDR_BIG + namlen + 1;
|
||||||
hdrp = (struct xcoff_ar_hdr_big *) bfd_alloc (abfd, amt);
|
ret = (struct areltdata *) bfd_malloc (amt);
|
||||||
if (hdrp == NULL)
|
if (ret == NULL)
|
||||||
{
|
return ret;
|
||||||
free (ret);
|
|
||||||
return NULL;
|
hdrp = (struct xcoff_ar_hdr_big *) (ret + 1);
|
||||||
}
|
|
||||||
memcpy (hdrp, &hdr, SIZEOF_AR_HDR_BIG);
|
memcpy (hdrp, &hdr, SIZEOF_AR_HDR_BIG);
|
||||||
if (bfd_bread ((char *) hdrp + SIZEOF_AR_HDR_BIG, namlen, abfd) != namlen)
|
if (bfd_bread ((char *) hdrp + SIZEOF_AR_HDR_BIG, namlen, abfd) != namlen)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue