From: Alan Modra Date: Wed, 26 Aug 2020 04:48:53 +0000 (+0930) Subject: PR26418 UBSAN: cache.c:386 null pointer fwrite X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9863cbb7bd3495107a5b1b4d887c95d859c9a35e;p=binutils-gdb.git PR26418 UBSAN: cache.c:386 null pointer fwrite PR 26418 * ecofflink.c (WRITE): Don't write size 0 chunks. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c296f6d89a3..2fd2321a429 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2020-08-26 Alan Modra + + PR 26418 + * ecofflink.c (WRITE): Don't write size 0 chunks. + 2020-08-26 Alan Modra * bfdio.c (bfd_get_file_size): Don't segv on NULL adata. diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c index e7b35f670db..7c9a7aeaa05 100644 --- a/bfd/ecofflink.c +++ b/bfd/ecofflink.c @@ -1489,10 +1489,12 @@ bfd_ecoff_write_debug (bfd *abfd, return FALSE; #define WRITE(ptr, count, size, offset) \ - BFD_ASSERT (symhdr->offset == 0 \ - || (bfd_vma) bfd_tell (abfd) == symhdr->offset); \ - if (bfd_bwrite (debug->ptr, (bfd_size_type) size * symhdr->count, abfd)\ - != size * symhdr->count) \ + BFD_ASSERT (symhdr->offset == 0 \ + || (bfd_vma) bfd_tell (abfd) == symhdr->offset); \ + if (size != 0 \ + && bfd_bwrite (debug->ptr, \ + (bfd_size_type) size * symhdr->count, \ + abfd) != size * symhdr->count) \ return FALSE; WRITE (line, cbLine, sizeof (unsigned char), cbLineOffset);