UserspaceEmulator+LibC: Have UE notice realloc() and update accounting

When a mallocation is shrunk/grown without moving, UE needs to update
its precise metadata about the mallocation, since it tracks *exactly*
how many bytes were allocated, not just the malloc chunk size.
This commit is contained in:
Andreas Kling
2020-11-08 10:10:41 +01:00
parent a0e25b2d31
commit c4dd77a170
4 changed files with 41 additions and 1 deletions

View File

@@ -111,6 +111,9 @@ void SoftCPU::did_receive_secret_data()
} else if (m_secret_data[0] == 2) {
if (auto* tracer = m_emulator.malloc_tracer())
tracer->target_did_free({}, m_secret_data[1]);
} else if (m_secret_data[0] == 3) {
if (auto* tracer = m_emulator.malloc_tracer())
tracer->target_did_realloc({}, m_secret_data[2], m_secret_data[1]);
} else {
ASSERT_NOT_REACHED();
}