nrf-usbd
nrf-usbd copied to clipboard
Possible undefined behavior in <Usbd as UsbBus>::write()
trafficstars
https://github.com/nrf-rs/nrf-usbd/blob/cbd7ed7508ab0feecbc939e6fa55976fbdf95c6a/src/usbd.rs#L378-L383
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.