This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
My personal opinion is that if tools don't understand the standard(s) properly, then it's bad form to pander to them just for the sake of shutting them up. I remember in years gone by people used to religiously write if (x != NULL) free (x); As well as needlessly increasting the line count it meant that coverage analysis would complain about untrialled branches. It got to be silly. Just my $0.02 On Fri, Jul 20, 2018 at 09:52:41AM -0600, Tom Tromey wrote: I built gdb with ubsan and ran the test suite. One complaint was due to bfd_get_elf_phdrs passing NULL to memcpy. This patch avoids the complaint. bfd/ChangeLog 2018-07-20 Tom Tromey <tom@tromey.com> * elf.c (bfd_get_elf_phdrs): Don't call memcpy with size 0. --- bfd/ChangeLog | 4 ++++ bfd/elf.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bfd/elf.c b/bfd/elf.c index 874629dc859..f72182788f9 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -11629,8 +11629,9 @@ bfd_get_elf_phdrs (bfd *abfd, void *phdrs) } num_phdrs = elf_elfheader (abfd)->e_phnum; - memcpy (phdrs, elf_tdata (abfd)->phdr, - num_phdrs * sizeof (Elf_Internal_Phdr)); + if (num_phdrs != 0) + memcpy (phdrs, elf_tdata (abfd)->phdr, + num_phdrs * sizeof (Elf_Internal_Phdr)); return num_phdrs; } -- 2.13.6 -- Avoid eavesdropping. Send strong encrypted email. PGP Public key ID: 1024D/2DE827B3 fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3 See http://sks-keyservers.net or any PGP keyserver for public key.
Attachment:
signature.asc
Description: Digital signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |