Skip to content

[lldb][LibCxx] Move incorrect nullptr check #96635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,14 +808,17 @@ 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.
ExecutionContext exe_ctx(location_sp->GetExecutionContextRef());
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);
Expand Down
Loading