[Lldb-commits] [lldb] [lldb] Fix user-after-free in CommandInterpreter (PR #187032)

via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 17 07:42:06 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)

<details>
<summary>Changes</summary>

The variable `matches` may be assigned the address of block-scope `local_matches`, which is defined in a scope strictly smaller than the scope of `matches`. Towards the end of the function, after `loacl_matches` has been destroyed, `matches` is accessed, possibly triggering a user-after-free.

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


1 Files Affected:

- (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+2-1) 


``````````diff
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 9aed946492632..d616becbf09d8 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1187,13 +1187,14 @@ CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, bool include_aliases,
       command_sp = pos->second;
   }
 
+  StringList local_matches;
+
   if (!exact && !command_sp) {
     // We will only get into here if we didn't find any exact matches.
 
     CommandObjectSP user_match_sp, user_mw_match_sp, alias_match_sp,
         real_match_sp;
 
-    StringList local_matches;
     if (matches == nullptr)
       matches = &local_matches;
 

``````````

</details>


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


More information about the lldb-commits mailing list