Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 072095a4 authored by Christopher Ferris's avatar Christopher Ferris Committed by android-build-merger
Browse files

Merge "Fix nullptr dereference." am: 8e1ac14f am: 209841d7

am: 9a0ea3ee

Change-Id: Id6f9de2a965021360661c00c167db939e0a04ece
parents 96b2532c 9a0ea3ee
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -39,6 +39,10 @@ const DwarfFde* DwarfSection::GetFdeFromPc(uint64_t pc) {
    return nullptr;
    return nullptr;
  }
  }
  const DwarfFde* fde = GetFdeFromOffset(fde_offset);
  const DwarfFde* fde = GetFdeFromOffset(fde_offset);
  if (fde == nullptr) {
    return nullptr;
  }

  // Guaranteed pc >= pc_start, need to check pc in the fde range.
  // Guaranteed pc >= pc_start, need to check pc in the fde range.
  if (pc < fde->pc_end) {
  if (pc < fde->pc_end) {
    return fde;
    return fde;
+13 −1
Original line number Original line Diff line number Diff line
@@ -399,13 +399,25 @@ TYPED_TEST_P(DwarfEhFrameTest, GetCieFde64) {
  EXPECT_EQ(0x20U, fde->cie->return_address_register);
  EXPECT_EQ(0x20U, fde->cie->return_address_register);
}
}


TYPED_TEST_P(DwarfEhFrameTest, GetFdeFromPc_fde_not_found) {
  this->eh_frame_->TestSetTableEntrySize(16);
  this->eh_frame_->TestSetFdeCount(1);

  typename DwarfEhFrame<TypeParam>::FdeInfo info;
  info.pc = 0x550;
  info.offset = 0x10500;
  this->eh_frame_->TestSetFdeInfo(0, info);

  ASSERT_EQ(nullptr, this->eh_frame_->GetFdeFromPc(0x800));
}

REGISTER_TYPED_TEST_CASE_P(DwarfEhFrameTest, Init, GetFdeInfoFromIndex_expect_cache_fail,
REGISTER_TYPED_TEST_CASE_P(DwarfEhFrameTest, Init, GetFdeInfoFromIndex_expect_cache_fail,
                           GetFdeInfoFromIndex_read_pcrel, GetFdeInfoFromIndex_read_datarel,
                           GetFdeInfoFromIndex_read_pcrel, GetFdeInfoFromIndex_read_datarel,
                           GetFdeInfoFromIndex_cached, GetFdeOffsetBinary_verify,
                           GetFdeInfoFromIndex_cached, GetFdeOffsetBinary_verify,
                           GetFdeOffsetSequential, GetFdeOffsetSequential_last_element,
                           GetFdeOffsetSequential, GetFdeOffsetSequential_last_element,
                           GetFdeOffsetSequential_end_check, GetFdeOffsetFromPc_fail_fde_count,
                           GetFdeOffsetSequential_end_check, GetFdeOffsetFromPc_fail_fde_count,
                           GetFdeOffsetFromPc_binary_search, GetFdeOffsetFromPc_sequential_search,
                           GetFdeOffsetFromPc_binary_search, GetFdeOffsetFromPc_sequential_search,
                           GetCieFde32, GetCieFde64);
                           GetCieFde32, GetCieFde64, GetFdeFromPc_fde_not_found);


typedef ::testing::Types<uint32_t, uint64_t> DwarfEhFrameTestTypes;
typedef ::testing::Types<uint32_t, uint64_t> DwarfEhFrameTestTypes;
INSTANTIATE_TYPED_TEST_CASE_P(, DwarfEhFrameTest, DwarfEhFrameTestTypes);
INSTANTIATE_TYPED_TEST_CASE_P(, DwarfEhFrameTest, DwarfEhFrameTestTypes);