diff options
author | Pavel Labath <pavel@labath.sk> | 2025-06-02 09:39:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-02 09:39:56 +0200 |
commit | e9fad0e91c49ca0f2669989dbad95664cbc9cbf3 (patch) | |
tree | 334be0ec84d6ca6d6db42f670c01fa2622c4b884 /lldb/source/Expression/Materializer.cpp | |
parent | 246d5da7fedb39ba1ad838032f2946535606631d (diff) | |
download | llvm-e9fad0e91c49ca0f2669989dbad95664cbc9cbf3.zip llvm-e9fad0e91c49ca0f2669989dbad95664cbc9cbf3.tar.gz llvm-e9fad0e91c49ca0f2669989dbad95664cbc9cbf3.tar.bz2 |
[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.
Diffstat (limited to 'lldb/source/Expression/Materializer.cpp')
-rw-r--r-- | lldb/source/Expression/Materializer.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp index 8d48b5e..79c804c 100644 --- a/lldb/source/Expression/Materializer.cpp +++ b/lldb/source/Expression/Materializer.cpp @@ -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); |