It is possible that there are no program headers in the module. Do not
attempt to dereference nullptr as a program header.
llvm-svn: 299591
size_t object_length;
#if defined(__ANDROID__)
Elf_Addr image_base =
- reinterpret_cast<Elf_Addr>(pinfo->dlpi_phdr) -
- reinterpret_cast<const Elf_Phdr *>(pinfo->dlpi_phdr)->p_offset;
+ pinfo->dlpi_phnum
+ ? reinterpret_cast<Elf_Addr>(pinfo->dlpi_phdr) -
+ reinterpret_cast<const Elf_Phdr *>(pinfo->dlpi_phdr)
+ ->p_offset
+ : 0;
#endif
for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) {