diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 6fa34e11705..a3ce931dbcb 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -232,12 +232,14 @@ Region* Process::allocate_region_with_vmobject(VirtualAddress vaddr, size_t size bool Process::deallocate_region(Region& region) { + OwnPtr region_protector; ScopedSpinLock lock(m_lock); + if (m_region_lookup_cache.region == ®ion) m_region_lookup_cache.region = nullptr; for (size_t i = 0; i < m_regions.size(); ++i) { if (&m_regions[i] == ®ion) { - m_regions.unstable_take(i); + region_protector = m_regions.unstable_take(i); return true; } }