[llvm] Make sure that the `std::optional<>` result is checked before being accessed (PR #116479)

Romain Thomas via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 23 06:36:32 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();
+    }
----------------
romainthomas wrote:

I fixed the coding in the commit 394adb0. 

How would you like to have the test case? Should I include the binary attached to the description of this issue in the LLVM repo? 

https://github.com/llvm/llvm-project/pull/116479


More information about the llvm-commits mailing list