Author: compnerd
Date: Wed Apr  5 16:29:38 2017
New Revision: 299591

URL: http://llvm.org/viewvc/llvm-project?rev=299591&view=rev
Log:
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.

Modified:
    libunwind/trunk/src/AddressSpace.hpp

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=299591&r1=299590&r2=299591&view=diff
==============================================================================
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Wed Apr  5 16:29:38 2017
@@ -394,8 +394,11 @@ inline bool LocalAddressSpace::findUnwin
         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++) {


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to