From cb09c37c55cc522ed50316413a07debf4536693f Mon Sep 17 00:00:00 2001 From: Julian Schindel Date: Wed, 29 Apr 2026 21:55:06 +0200 Subject: [PATCH] vm-migration: replace `as ` casts with safer alternatives `as` casts can change mutability, which quickly leads to undefined behavior. Signed-off-by: Julian Schindel --- vm-migration/src/protocol.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm-migration/src/protocol.rs b/vm-migration/src/protocol.rs index f927d7a36..7cccc6645 100644 --- a/vm-migration/src/protocol.rs +++ b/vm-migration/src/protocol.rs @@ -444,7 +444,7 @@ impl MemoryRangeTable { pub fn write_to(&self, fd: &mut dyn Write) -> Result<(), MigratableError> { // SAFETY: the slice is constructed with the correct arguments fd.write_all(unsafe { - std::slice::from_raw_parts(self.data.as_ptr() as *const u8, self.length() as usize) + std::slice::from_raw_parts(self.data.as_ptr().cast(), self.length() as usize) }) .map_err(MigratableError::MigrateSocket) }