From 7ca371dba5d612ff1cdaa4ffe33474c1993fbe7f Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 28 Aug 2020 21:45:49 +0930 Subject: [PATCH] PR26418 UBSAN: cache.c:386 null pointer fwrite The previous "fix" tested the wrong value. PR 26418 * ecofflink.c (WRITE): Really don't write zero size chunks. --- bfd/ChangeLog | 5 +++++ bfd/ecofflink.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index bf082fc4cb6..805d1568b1c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2020-08-28 Alan Modra + + PR 26418 + * ecofflink.c (WRITE): Really don't write zero size chunks. + 2020-08-28 Tuckker PR 26543 diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c index 7c9a7aeaa05..e8c3f9f188e 100644 --- a/bfd/ecofflink.c +++ b/bfd/ecofflink.c @@ -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) \ -- 2.30.2