mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 05:32:28 +08:00
[lldb] Refactor away UB in SBValue::GetLoadAddress (#141799)
The problem was in calling GetLoadAddress on a value in the error state, where `ValueObject::GetLoadAddress` could end up accessing the uninitialized "address type" by-ref return value from `GetAddressOf`. This probably happened because each function expected the other to initialize it. We can guarantee initialization by turning this into a proper return value. I've added a test, but it only (reliably) crashes if lldb is built with ubsan.
This commit is contained in:
@@ -508,10 +508,8 @@ public:
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
AddressType address_type = eAddressTypeInvalid;
|
||||
const bool scalar_is_load_address = false;
|
||||
lldb::addr_t addr_of_valobj =
|
||||
valobj_sp->GetAddressOf(scalar_is_load_address, &address_type);
|
||||
valobj_sp->GetAddressOf(/*scalar_is_load_address=*/false).address;
|
||||
if (addr_of_valobj != LLDB_INVALID_ADDRESS) {
|
||||
Status write_error;
|
||||
map.WritePointerToMemory(load_addr, addr_of_valobj, write_error);
|
||||
|
||||
Reference in New Issue
Block a user