https://github.com/lhames created https://github.com/llvm/llvm-project/pull/215710
ClangUserExpression::GetCppObjectPointer dereferenced the ValueObjectSP returned by GetObjectPointerValueObject before checking it for null. Fix by moving the existing check above the child lookups. >From a7a6de58241b2fb1cf92532d109e68157f4701d5 Mon Sep 17 00:00:00 2001 From: Lang Hames <[email protected]> Date: Wed, 12 Aug 2026 12:18:42 +1000 Subject: [PATCH] [lldb] Guard against null dereference in GetCppObjectPointer ClangUserExpression::GetCppObjectPointer dereferenced the ValueObjectSP returned by GetObjectPointerValueObject before checking it for null. Fix by moving the existing check above the child lookups. --- .../Plugins/ExpressionParser/Clang/ClangUserExpression.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp index b7ebb6dfd5551..62652e200baca 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -854,6 +854,9 @@ lldb::addr_t ClangUserExpression::GetCppObjectPointer( auto valobj_sp = GetObjectPointerValueObject(std::move(frame_sp), object_name, err); + if (!err.Success() || !valobj_sp) + return LLDB_INVALID_ADDRESS; + // We're inside a C++ class method. This could potentially be an unnamed // lambda structure. If the lambda captured a "this", that should be // the object pointer. @@ -862,9 +865,6 @@ lldb::addr_t ClangUserExpression::GetCppObjectPointer( else if (auto cv_this_child_sp = valobj_sp->GetChildMemberWithName("__this")) valobj_sp = cv_this_child_sp; - if (!err.Success() || !valobj_sp.get()) - return LLDB_INVALID_ADDRESS; - lldb::addr_t ret = valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); if (ret == LLDB_INVALID_ADDRESS) { _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
