diff options
author | Tom Tromey <tom@tromey.com> | 2018-07-15 18:07:40 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-07-23 08:14:00 -0600 |
commit | 01bcaf636ad0b1d5fe44a21917ec900af86072a8 (patch) | |
tree | 98ffe83dd19e92881ae4b0319e4cfa9604a46f59 /bfd/elf.c | |
parent | e2b7fbc46d08605bd2807678475e01be42e589e6 (diff) | |
download | gdb-01bcaf636ad0b1d5fe44a21917ec900af86072a8.zip gdb-01bcaf636ad0b1d5fe44a21917ec900af86072a8.tar.gz gdb-01bcaf636ad0b1d5fe44a21917ec900af86072a8.tar.bz2 |
Avoid ubsan complaint in BFD
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-23 Tom Tromey <tom@tromey.com>
* elf.c (bfd_get_elf_phdrs): Don't call memcpy with size 0.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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; } |