Avoid updating memory protection on allocations that have the right protection.

This commit is contained in:
Michael Chesser
2021-05-25 09:19:15 +09:30
committed by Anton Kirilov
parent 54896ac86d
commit 61ecccf306

View File

@@ -179,6 +179,8 @@ impl Memory {
}
}
}
self.executable = self.allocations.len();
}
/// Set all memory allocated in this `Memory` up to now as readonly.
@@ -208,12 +210,15 @@ impl Memory {
}
}
}
self.executable = self.allocations.len();
}
/// Frees all allocated memory regions that would be leaked otherwise.
/// Likely to invalidate existing function pointers, causing unsafety.
pub(crate) unsafe fn free_memory(&mut self) {
self.allocations.clear();
self.executable = 0;
}
}