about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSean Cross <sean@xobs.io>2023-12-24 14:51:28 +0800
committerSean Cross <sean@xobs.io>2024-01-13 09:13:55 -0800
commit944dc212685a4f17db144d14459ee4bc3ffd3423 (patch)
tree5cbb714799161faa4644e83dd0241e66575b727c
parentdee1c260b8ab3d093dc571a0954f645a43b822bc (diff)
downloadrust-944dc212685a4f17db144d14459ee4bc3ffd3423.tar.gz
rust-944dc212685a4f17db144d14459ee4bc3ffd3423.zip
xous: ffi: correct size of freed memory
The amount of memory allocated was multiplied by sizeof::<T>(), so the
amount of memory to be freed should also be multiplied by sizeof::<T>().

Signed-off-by: Sean Cross <sean@xobs.io>
-rw-r--r--library/std/src/os/xous/ffi.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/std/src/os/xous/ffi.rs b/library/std/src/os/xous/ffi.rs
index 0a7f9a10d4d..1df4fbab7f7 100644
--- a/library/std/src/os/xous/ffi.rs
+++ b/library/std/src/os/xous/ffi.rs
@@ -407,7 +407,7 @@ pub(crate) unsafe fn map_memory<T>(
 pub(crate) unsafe fn unmap_memory<T>(range: *mut [T]) -> Result<(), Error> {
     let mut a0 = Syscall::UnmapMemory as usize;
     let mut a1 = range.as_mut_ptr() as usize;
-    let a2 = range.len();
+    let a2 = range.len() * core::mem::size_of::<T>();
     let a3 = 0;
     let a4 = 0;
     let a5 = 0;