Skip to content

Commit dbb1ca2

Browse files
committed
Make sure that the std::optional<> result is checked before being accessed.
1 parent 0b344b4 commit dbb1ca2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/DebugInfo/DWARF/DWARFDie.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,13 @@ Expected<DWARFAddressRangesVector> DWARFDie::getAddressRanges() const {
394394

395395
std::optional<DWARFFormValue> Value = find(DW_AT_ranges);
396396
if (Value) {
397+
std::optional<uint64_t> SecOff = Value->getAsSectionOffset();
398+
if (!SecOff) {
399+
return DWARFAddressRangesVector();
400+
}
397401
if (Value->getForm() == DW_FORM_rnglistx)
398-
return U->findRnglistFromIndex(*Value->getAsSectionOffset());
399-
return U->findRnglistFromOffset(*Value->getAsSectionOffset());
402+
return U->findRnglistFromIndex(*SecOff);
403+
return U->findRnglistFromOffset(*SecOff);
400404
}
401405
return DWARFAddressRangesVector();
402406
}

0 commit comments

Comments
 (0)