Skip to content

Commit

Permalink
prevent aggresive optimizations over const_casted buf
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyrchien committed Oct 14, 2024
1 parent a2612f8 commit 067424d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lightws"
version = "0.6.11"
version = "0.6.12"
authors = ["zephyr <[email protected]>"]
description = "Lightweight websocket implement for stream transmission."
repository = "https://github.com/zephyrchien/lightws"
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(incomplete_features)]
#![allow(clippy::blocks_in_conditions)]
#![feature(const_slice_from_raw_parts_mut)]
#![feature(read_buf)]
#![feature(core_io_borrowed_buf)]
#![feature(specialization)]
Expand Down
4 changes: 3 additions & 1 deletion src/stream/detail/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ impl<Role: AutoMaskClientRole> WriteFrameHeadTrait<Role> for WriteFrameHead<Role
role.mask_key().to_key()
};

// !! const_cast a immutable reference
unsafe {
// !! const_cast a immutable reference
let buf = const_cast(buf);
// prevent too aggresive optimizations
let buf = std::hint::black_box(buf);
apply_mask4(key, buf);
}

Expand Down

0 comments on commit 067424d

Please sign in to comment.