From 5fcfd6a2aaa7f79aedd43350114e9180a158e9b7 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 5 Aug 2021 16:58:20 +0800 Subject: [PATCH] xous: don't allow mutable slices from immutable ranges If a MemoryRange is defined as immutable, don't allow `as_mut_slice()` to be called. This is an API-breaking change. Signed-off-by: Sean Cross --- xous-rs/src/definitions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xous-rs/src/definitions.rs b/xous-rs/src/definitions.rs index 643fc7fb2..379d7c920 100644 --- a/xous-rs/src/definitions.rs +++ b/xous-rs/src/definitions.rs @@ -703,7 +703,7 @@ impl MemoryRange { /// For example, if the allocation is 4096 bytes, then the resulting /// `&[u8]` would have 4096 elements, `&[u16]` would have 2048, and /// `&[u32]` would have 1024. Values are rounded down. - pub fn as_slice_mut(&self) -> &mut [T] { + pub fn as_slice_mut(&mut self) -> &mut [T] { // This is safe because the pointer and length are guaranteed to // be valid, as long as the user hasn't already called `as_ptr()` // and done something unsound with the resulting pointer.