summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2017-04-05 21:29:38 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2017-04-05 21:29:38 +0000
commit61091fd7813459bc4fb740518fba4ada66a8afe5 (patch)
tree1743d336f04d8b24bfc665179d98b7afdd77324d
parent338c1479b2a6e0c14237db10311cb1af9bc6d393 (diff)
downloadlibunwind_llvm-61091fd7813459bc4fb740518fba4ada66a8afe5.tar.gz
AddressSpace: fix DWARF based unwinding handling on Android
It is possible that there are no program headers in the module. Do not attempt to dereference nullptr as a program header. git-svn-id: https://llvm.org/svn/llvm-project/libunwind/trunk@299591 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--src/AddressSpace.hpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/AddressSpace.hpp b/src/AddressSpace.hpp
index ab6e0d5..54b258e 100644
--- a/src/AddressSpace.hpp
+++ b/src/AddressSpace.hpp
@@ -394,8 +394,11 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
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++) {