llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) <details> <summary>Changes</summary> Found this while skimming this code. Don't have a reproducible test case for this but the nullptr check should clearly occur before we try to dereference `location_sp`. --- Full diff: https://github.com/llvm/llvm-project/pull/96635.diff 1 Files Affected: - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp (+4-1) ``````````diff diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index b0e6fb7d6f5af..0f9f93b727ce8 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -808,6 +808,9 @@ ExtractLibcxxStringInfo(ValueObject &valobj) { size = (layout == StringLayout::DSC) ? size_mode_value : ((size_mode_value >> 1) % 256); + if (!location_sp) + return {}; + // When the small-string optimization takes place, the data must fit in the // inline string buffer (23 bytes on x86_64/Darwin). If it doesn't, it's // likely that the string isn't initialized and we're reading garbage. @@ -815,7 +818,7 @@ ExtractLibcxxStringInfo(ValueObject &valobj) { const std::optional<uint64_t> max_bytes = location_sp->GetCompilerType().GetByteSize( exe_ctx.GetBestExecutionContextScope()); - if (!max_bytes || size > *max_bytes || !location_sp) + if (!max_bytes || size > *max_bytes) return {}; return std::make_pair(size, location_sp); `````````` </details> https://github.com/llvm/llvm-project/pull/96635 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits