[Lldb-commits] [lldb] [lldb] Speedup AppleObjCRuntimeV2 UpdateIfNeeded (PR #211774)
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Fri Jul 24 06:31:36 PDT 2026
================
@@ -1819,23 +1821,35 @@ llvm::Error AppleObjCRuntimeV2::SharedCacheImageHeaders::UpdateIfNeeded() {
constexpr lldb::addr_t metadata_size =
sizeof(uint32_t) + sizeof(uint32_t); // count + entsize
- Status error;
+ /// Sanity check: m_count and m_entsize are external input, guard against
+ /// invalid values using an arbitrary 1GB maximum size.
+ const size_t memory_needed = static_cast<size_t>(m_count) * m_entsize;
----------------
Teemperor wrote:
You could also do this:
```cpp
if (llvm::AddOverflow<size_t>(m_count, m_entsize, /*Result=*/memory_needed))
return llvm::createStringError("Shared Cache size computation overflowed");
```
Having said that, we essentially just blindly read what the runtime tells us, so it's not really important that we sanitise input here...
https://github.com/llvm/llvm-project/pull/211774
More information about the lldb-commits
mailing list