Fix potential segfault

Code in vms-lib.c leaves arch_header NULL.

	* bfdio.c (bfd_get_file_size): Don't segfault on NULL arch_header.
This commit is contained in:
Alan Modra 2020-05-23 16:51:30 +09:30
parent 3f3c36087e
commit c892b44730
2 changed files with 7 additions and 2 deletions

View File

@ -1,3 +1,7 @@
2020-05-23 Alan Modra <amodra@gmail.com>
* bfdio.c (bfd_get_file_size): Don't segfault on NULL arch_header.
2020-05-22 Alan Modra <amodra@gmail.com>
PR 25882

View File

@ -495,8 +495,9 @@ bfd_get_file_size (bfd *abfd)
struct areltdata *adata = (struct areltdata *) abfd->arelt_data;
archive_size = adata->parsed_size;
/* If the archive is compressed we can't compare against file size. */
if (memcmp (((struct ar_hdr *) adata->arch_header)->ar_fmag,
"Z\012", 2) == 0)
if (adata->arch_header != NULL
&& memcmp (((struct ar_hdr *) adata->arch_header)->ar_fmag,
"Z\012", 2) == 0)
return archive_size;
abfd = abfd->my_archive;
}