瀏覽代碼

UserspaceEmulator: Skip freed mallocations in reachability scan

Something being reachable from a freed mallocation doesn't make it
actually reachable.

Thanks to Jonas Bengtsson for spotting this! :^)
Andreas Kling 5 年之前
父節點
當前提交
df58ea808e
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      DevTools/UserspaceEmulator/MallocTracer.cpp

+ 2 - 0
DevTools/UserspaceEmulator/MallocTracer.cpp

@@ -146,6 +146,8 @@ bool MallocTracer::is_reachable(const Mallocation& mallocation) const
     for (auto& other_mallocation : m_mallocations) {
         if (&mallocation == &other_mallocation)
             continue;
+        if (other_mallocation.freed)
+            continue;
         size_t pointers_in_mallocation = other_mallocation.size / sizeof(u32);
         for (size_t i = 0; i < pointers_in_mallocation; ++i) {
             auto value = Emulator::the().mmu().read32({ 0x20, other_mallocation.address + i * sizeof(u32) });