* Fix potential segfault
@ 2020-05-23 7:26 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2020-05-23 7:26 UTC (permalink / raw)
To: binutils
Code in vms-lib.c leaves arch_header NULL.
* bfdio.c (bfd_get_file_size): Don't segfault on NULL arch_header.
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 5ef3ec493e..5f144bc7f3 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -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;
}
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-05-23 7:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-23 7:26 Fix potential segfault Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).