|
let mut ram_buf: MaybeUninit<[u8; 64]> = MaybeUninit::uninit(); |
|
unsafe { |
|
let slice = &mut *ram_buf.as_mut_ptr(); |
|
slice[..buf.len()].copy_from_slice(buf); |
|
} |
|
let ram_buf = unsafe { ram_buf.assume_init() }; |
Line 380 looks like UB because we're creating a mutable reference to unitialized memory. Some write method (from MaybeUninit or the raw pointer type) should be used.
Line 383 also looks like UB because we did not initialize the whole array.
Probably the simpler solution is to use a regular array and avoid usage of unsafe.
nrf-usbd/src/usbd.rs
Lines 378 to 383 in cbd7ed7
Line 380 looks like UB because we're creating a mutable reference to unitialized memory. Some
writemethod (fromMaybeUninitor the raw pointer type) should be used.Line 383 also looks like UB because we did not initialize the whole array.
Probably the simpler solution is to use a regular array and avoid usage of unsafe.