mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-12 08:31:21 +00:00
Merge #1069
1069: Add fn for splitting borrow of memory & data in Ctx, use in WASI r=MarkMcCaskey a=MarkMcCaskey Fixes a soundness issue / some undefined behavior # Review - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <mark@wasmer.io> Co-authored-by: Mark McCaskey <5770194+markmccaskey@users.noreply.github.com>
This commit is contained in:
@ -401,6 +401,21 @@ impl Ctx {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get access to [`Memory`] and mutable access to the user defined data
|
||||
/// field as the type, `T`.
|
||||
///
|
||||
/// This method is required to access both at the same time.
|
||||
/// This is useful for updating a data type that stores information about
|
||||
/// locations in Wasm memory.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// This function must be called with the same type, `T`, that the `data`
|
||||
/// was initialized with.
|
||||
pub unsafe fn memory_and_data_mut<T>(&mut self, mem_index: u32) -> (&Memory, &mut T) {
|
||||
(self.memory(mem_index), &mut *(self.data as *mut T))
|
||||
}
|
||||
|
||||
/// Gives access to the emscripten symbol map, used for debugging
|
||||
pub unsafe fn borrow_symbol_map(&self) -> &Option<HashMap<u32, String>> {
|
||||
&(*self.module).info.em_symbol_map
|
||||
|
Reference in New Issue
Block a user