From: Alan Modra Date: Fri, 28 Aug 2020 13:36:47 +0000 (+0930) Subject: PR26418 UBSAN: cache.c:386 null pointer fwrite X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=07319accdf8eecc5111b343802dadd067f683d26;p=binutils-gdb.git PR26418 UBSAN: cache.c:386 null pointer fwrite And some more. PR 26418 * ecofflink.c (bfd_ecoff_write_accumulated_debug): Don't write zero size buffers. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 805d1568b1c..33cc1c474e1 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2020-08-28 Alan Modra + + PR 26418 + * ecofflink.c (bfd_ecoff_write_accumulated_debug): Don't write + zero size buffers. + 2020-08-28 Alan Modra PR 26418 diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c index e8c3f9f188e..111ffdbc379 100644 --- a/bfd/ecofflink.c +++ b/bfd/ecofflink.c @@ -1652,7 +1652,7 @@ bfd_ecoff_write_accumulated_debug (void * handle, /* The external strings and symbol are not converted over to using shuffles. FIXME: They probably should be. */ amt = debug->symbolic_header.issExtMax; - if (bfd_bwrite (debug->ssext, amt, abfd) != amt) + if (amt != 0 && bfd_bwrite (debug->ssext, amt, abfd) != amt) goto error_return; if ((debug->symbolic_header.issExtMax & (swap->debug_align - 1)) != 0) { @@ -1682,7 +1682,7 @@ bfd_ecoff_write_accumulated_debug (void * handle, == (bfd_vma) bfd_tell (abfd))); amt = debug->symbolic_header.iextMax * swap->external_ext_size; - if (bfd_bwrite (debug->external_ext, amt, abfd) != amt) + if (amt != 0 && bfd_bwrite (debug->external_ext, amt, abfd) != amt) goto error_return; free (space);