Avoid ubsan complaint in BFD
[deliverable/binutils-gdb.git] / bfd / elf.c
index 874629dc8594ec322e2fee613213fd3081832670..f72182788f9e2c5428fb23b3d951de2502d0f814 100644 (file)
--- 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;
 }
This page took 0.026456 seconds and 4 git commands to generate.