sled icon indicating copy to clipboard operation
sled copied to clipboard

Prevent UB with `assume_init` on uninit bytes

Open clubby789 opened this issue 1 year ago • 0 comments

If size_of::<F> < size_of::<Data>, the remaining bytes would be uninitialised - thus, calling assume_init would cause UB, as noted by Miri. Storing the data as MaybeUninit and casting to the correct FnOnce() object before reading it fixes this, only using initialized bytes.

clubby789 avatar Sep 11 '22 15:09 clubby789