From: Alan Modra Date: Wed, 26 Aug 2020 02:02:51 +0000 (+0930) Subject: asan: alpha-vms: mmember access within null pointer X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c01de193638c9022411ae0542a457b9d68723013;p=binutils-gdb.git asan: alpha-vms: mmember access within null pointer * bfdio.c (bfd_get_file_size): Don't segv on NULL adata. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index fe440e89c6b..c296f6d89a3 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,7 @@ +2020-08-26 Alan Modra + + * bfdio.c (bfd_get_file_size): Don't segv on NULL adata. + 2020-08-26 Alan Modra PR 26415 diff --git a/bfd/bfdio.c b/bfd/bfdio.c index 5f144bc7f3f..86b696bba9c 100644 --- a/bfd/bfdio.c +++ b/bfd/bfdio.c @@ -493,13 +493,17 @@ bfd_get_file_size (bfd *abfd) && !bfd_is_thin_archive (abfd->my_archive)) { 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 (adata->arch_header != NULL - && memcmp (((struct ar_hdr *) adata->arch_header)->ar_fmag, - "Z\012", 2) == 0) - return archive_size; - abfd = abfd->my_archive; + if (adata != NULL) + { + archive_size = adata->parsed_size; + /* If the archive is compressed we can't compare against + file size. */ + 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; + } } file_size = bfd_get_size (abfd);