Here, a packet is filled by bytes from a message:
|
let packet: u32 = 0; |
|
let ptr = &packet as *const u32 as *mut u8; |
|
for i in 0..nbytes { |
|
unsafe { *ptr.offset(i as isize) = message[i] }; |
|
} |
This is undefined behaviour, because the address of an immutable u32 is taken and cast to a *mut u8, which is then written to in an unsafe block.
I have fixes ready in #136 but these are part of a rather large patchset, so if you like I can send a small patch ahead, too.
Here, a packet is filled by bytes from a message:
midir/src/backend/winmm/mod.rs
Lines 509 to 513 in db24d55
This is undefined behaviour, because the address of an immutable
u32is taken and cast to a*mut u8, which is then written to in anunsafeblock.I have fixes ready in #136 but these are part of a rather large patchset, so if you like I can send a small patch ahead, too.