mirror of
https://github.com/actix/actix-web.git
synced 2024-12-21 07:36:43 +00:00
remove unsafe
This commit is contained in:
parent
1c3b32169e
commit
5b7aed101a
1 changed files with 8 additions and 9 deletions
|
@ -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 _)
|
||||
};
|
||||
apply_mask(p, mask);
|
||||
}
|
||||
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
|
||||
};
|
||||
|
||||
Ok(Async::Ready(Some(Frame {
|
||||
finished,
|
||||
|
|
Loading…
Reference in a new issue