Set all memory allocated in this `Memory` up to now as readonly.
(&mut self)
| 112 | |
| 113 | /// Set all memory allocated in this `Memory` up to now as readonly. |
| 114 | pub(crate) fn set_readonly(&mut self) -> ModuleResult<()> { |
| 115 | self.finish_current(); |
| 116 | |
| 117 | for &PtrLen { ptr, len, .. } in self.non_protected_allocations_iter() { |
| 118 | unsafe { |
| 119 | region::protect(ptr, len, region::Protection::READ).map_err(|e| { |
| 120 | ModuleError::Backend( |
| 121 | anyhow::Error::new(e).context("unable to make memory readonly"), |
| 122 | ) |
| 123 | })?; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | self.already_protected = self.allocations.len(); |
| 128 | Ok(()) |
| 129 | } |
| 130 | |
| 131 | /// Iterates non protected memory allocations that are of not zero bytes in size. |
| 132 | fn non_protected_allocations_iter(&self) -> impl Iterator<Item = &PtrLen> { |
no test coverage detected