blob: 54847444e0b89ee15829cb4a3cc2e824f8df84cc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
use bytemuck::TransparentWrapper;
#[repr(transparent)]
struct Wrap(Box<u32>);
// SAFETY: it's #[repr(transparent)]
unsafe impl TransparentWrapper<Box<u32>> for Wrap {}
fn main() {
let value = Box::new(5);
// This used to duplicate the wrapped value, creating a double free :(
Wrap::wrap(value);
}
|