vm-migration: replace as <pointer> casts with safer alternatives

`as` casts can change mutability, which quickly leads to undefined
behavior.

Signed-off-by: Julian Schindel <mail@arctic-alpaca.de>
This commit is contained in:
Julian Schindel
2026-04-29 21:55:06 +02:00
committed by Rob Bradford
parent 8abd9d7db5
commit cb09c37c55
+1 -1
View File
@@ -444,7 +444,7 @@ impl MemoryRangeTable {
pub fn write_to(&self, fd: &mut dyn Write) -> Result<(), MigratableError> { pub fn write_to(&self, fd: &mut dyn Write) -> Result<(), MigratableError> {
// SAFETY: the slice is constructed with the correct arguments // SAFETY: the slice is constructed with the correct arguments
fd.write_all(unsafe { 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) .map_err(MigratableError::MigrateSocket)
} }