diff options
author | Alan Modra <amodra@gmail.com> | 2020-05-23 16:51:30 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-05-23 16:56:38 +0930 |
commit | c892b44730bb1a66d614fd47fabe47555ca83b3b (patch) | |
tree | c5f4c1c47c172b2d8c6f4e4481daeda0c2c0db98 /bfd/bfdio.c | |
parent | 3f3c36087ec4667e285b487e668da73614993828 (diff) | |
download | gdb-c892b44730bb1a66d614fd47fabe47555ca83b3b.zip gdb-c892b44730bb1a66d614fd47fabe47555ca83b3b.tar.gz gdb-c892b44730bb1a66d614fd47fabe47555ca83b3b.tar.bz2 |
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.
Diffstat (limited to 'bfd/bfdio.c')
-rw-r--r-- | bfd/bfdio.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/bfd/bfdio.c b/bfd/bfdio.c index 5ef3ec4..5f144bc 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; } |