[Lldb-commits] [lldb] [LLDB] Check comp_unit before accessing it in DIL (PR #147955)

via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 10 06:02:28 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Ilia Kuklin (kuilpd)

<details>
<summary>Changes</summary>

Check `symbol_context.comp_unit` before accessing it to avoid `nullptr` dereferencing.

---
Full diff: https://github.com/llvm/llvm-project/pull/147955.diff


1 Files Affected:

- (modified) lldb/source/ValueObject/DILEval.cpp (+3-2) 


``````````diff
diff --git a/lldb/source/ValueObject/DILEval.cpp b/lldb/source/ValueObject/DILEval.cpp
index 8ca9b4215985d..fd3f9f8724608 100644
--- a/lldb/source/ValueObject/DILEval.cpp
+++ b/lldb/source/ValueObject/DILEval.cpp
@@ -50,8 +50,9 @@ lldb::ValueObjectSP LookupGlobalIdentifier(
   // Get a global variables list without the locals from the current frame
   SymbolContext symbol_context =
       stack_frame->GetSymbolContext(lldb::eSymbolContextCompUnit);
-  lldb::VariableListSP variable_list =
-      symbol_context.comp_unit->GetVariableList(true);
+  lldb::VariableListSP variable_list;
+  if (symbol_context.comp_unit)
+    variable_list = symbol_context.comp_unit->GetVariableList(true);
 
   name_ref.consume_front("::");
   lldb::ValueObjectSP value_sp;

``````````

</details>


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


More information about the lldb-commits mailing list