Author: Lang Hames Date: 2026-08-13T11:49:22+10:00 New Revision: e81a124d05cacedc6f22a08602552dc4becec4a9
URL: https://github.com/llvm/llvm-project/commit/e81a124d05cacedc6f22a08602552dc4becec4a9 DIFF: https://github.com/llvm/llvm-project/commit/e81a124d05cacedc6f22a08602552dc4becec4a9.diff LOG: [lldb] Guard against null dereference in GetCppObjectPointer (#215710) ClangUserExpression::GetCppObjectPointer dereferenced the ValueObjectSP returned by GetObjectPointerValueObject before checking it for null. Fix by moving the existing check above the child lookups. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Removed: ################################################################################ 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
