Skip to content

Commit 50218a6

Browse files
committed
Check the buffer size in ValueObjectDynamicValue
1 parent f914d61 commit 50218a6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lldb/source/ValueObject/ValueObjectDynamicValue.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,13 @@ bool ValueObjectDynamicValue::UpdateValue() {
240240
if (m_address.IsValid())
241241
SetValueDidChange(true);
242242

243-
// If we found a host address, point to the buffer in host memory.
244-
// Later on this function will copy the buffer over.
245-
if (value_type == Value::ValueType::HostAddress && !local_buffer.empty()) {
243+
auto *exe_scope = exe_ctx.GetBestExecutionContextScope();
244+
// If we found a host address, and the dynamic type fits in the local buffer
245+
// that was found, point to thar buffer. Later on this function will copy
246+
// the buffer over.
247+
if (value_type == Value::ValueType::HostAddress && !local_buffer.empty() &&
248+
local_buffer.size() <=
249+
m_dynamic_type_info.GetCompilerType().GetByteSize(exe_scope)) {
246250
m_value.GetScalar() = (uint64_t)local_buffer.data();
247251
m_address = LLDB_INVALID_ADDRESS;
248252
} else {

0 commit comments

Comments
 (0)