Fix nullptr dereference.
If an entry is found in .eh_frame_hdr, but it's not properly in .eh_frame,
then the code would crash. The assumption that the header always points
to valid fde data is not guaranteed.
Bug: 68813077
Test: Passes new unit test that crashed before the change.
Change-Id: I914d9bda0d442cd232e2a056ae490301a8850105
diff --git a/libunwindstack/DwarfSection.cpp b/libunwindstack/DwarfSection.cpp
index 2292168..91aef80 100644
--- a/libunwindstack/DwarfSection.cpp
+++ b/libunwindstack/DwarfSection.cpp
@@ -39,6 +39,10 @@
return nullptr;
}
const DwarfFde* fde = GetFdeFromOffset(fde_offset);
+ if (fde == nullptr) {
+ return nullptr;
+ }
+
// Guaranteed pc >= pc_start, need to check pc in the fde range.
if (pc < fde->pc_end) {
return fde;