1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-28 01:32:57 +01:00

remove unsafe

This commit is contained in:
Nikolay Kim 2018-07-06 13:54:43 +06:00
parent 1c3b32169e
commit 5b7aed101a

View File

@ -260,15 +260,14 @@ impl Frame {
}
// unmask
if let Some(mask) = mask {
// Unsafe: request body stream is owned by WsStream. only one ref to
// bytes exists. Bytes object get freezed in continuous non-overlapping blocks
let p: &mut [u8] = unsafe {
let ptr: &[u8] = &data;
&mut *(ptr as *const _ as *mut _)
let data = if let Some(mask) = mask {
let mut buf = BytesMut::new();
buf.extend_from_slice(&data);
apply_mask(&mut buf, mask);
buf.freeze()
} else {
data
};
apply_mask(p, mask);
}
Ok(Async::Ready(Some(Frame {
finished,