[llvm] Make sure that the `std::optional<>` result is checked before being accessed (PR #116479)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 25 09:23:27 PST 2024
================
@@ -394,9 +394,13 @@ Expected<DWARFAddressRangesVector> DWARFDie::getAddressRanges() const {
std::optional<DWARFFormValue> Value = find(DW_AT_ranges);
if (Value) {
+ std::optional<uint64_t> SecOff = Value->getAsSectionOffset();
+ if (!SecOff) {
+ return DWARFAddressRangesVector();
+ }
----------------
dwblaikie wrote:
We try to avoid checking in binary files, especially unbounded ones/ones without source code/asm code we could use to regenerate them.
Could you run the fixed dwarfdump on your test case, dump it out, then try to create a test case in assembly by hand that is minimal and exercises the interesting codepath (ie: crashes without this patch applied)?
https://github.com/llvm/llvm-project/pull/116479
More information about the llvm-commits
mailing list