mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: 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:
committed by
Rob Bradford
parent
8b101fb890
commit
ae7113e1d4
@@ -396,7 +396,7 @@ impl VsockPacket {
|
||||
PacketBuffer::Borrowed { ptr, len } => {
|
||||
// SAFETY: bound checks have already been performed when creating the packet
|
||||
// from the virtq descriptor.
|
||||
Some(unsafe { std::slice::from_raw_parts(*ptr as *const u8, *len) })
|
||||
Some(unsafe { std::slice::from_raw_parts((*ptr).cast(), *len) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user