PR26418 UBSAN: cache.c:386 null pointer fwrite
authorAlan Modra <amodra@gmail.com>
Fri, 28 Aug 2020 12:15:49 +0000 (21:45 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 28 Aug 2020 12:29:29 +0000 (21:59 +0930)
The previous "fix" tested the wrong value.

PR 26418
* ecofflink.c (WRITE): Really don't write zero size chunks.

bfd/ChangeLog
bfd/ecofflink.c

index bf082fc4cb63f885063f9b948cb291d2600f5580..805d1568b1c35ea5991720778f61e5c33b528855 100644 (file)
@@ -1,3 +1,8 @@
+2020-08-28  Alan Modra  <amodra@gmail.com>
+
+       PR 26418
+       * ecofflink.c (WRITE): Really don't write zero size chunks.
+
 2020-08-28  Tuckker  <tuckkern+sourceware@gmail.com>
 
        PR 26543
index 7c9a7aeaa0513c71c731ee3f483515340c89cca8..e8c3f9f188ef3e41378d8a8ad31710bb25ad687a 100644 (file)
@@ -1491,7 +1491,7 @@ bfd_ecoff_write_debug (bfd *abfd,
 #define WRITE(ptr, count, size, offset) \
   BFD_ASSERT (symhdr->offset == 0                              \
              || (bfd_vma) bfd_tell (abfd) == symhdr->offset);  \
-  if (size != 0                                                        \
+  if (symhdr->count != 0                                       \
       && bfd_bwrite (debug->ptr,                               \
                     (bfd_size_type) size * symhdr->count,      \
                     abfd) != size * symhdr->count)             \