Skip to content

Commit ae9d019

Browse files
committed
iui: draw: use mem::MaybeUninit in identity()
The `mem::uninitialized()` function is considered undefined behavior, and is therefore heavily deprecated. Instead, `mem::MaybeUninit` is preferred. Convert the usage of `mem::uninitialized()` into `mem::MaybeUninit` in the `Transform::identity()` function to remove this UB. Signed-off-by: Sean Cross <[email protected]>
1 parent 50e68f9 commit ae9d019

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

iui/src/draw/transform.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ impl Transform {
1919
/// Create a new Transform that does nothing.
2020
pub fn identity() -> Transform {
2121
unsafe {
22-
let mut matrix = mem::uninitialized();
23-
ui_sys::uiDrawMatrixSetIdentity(&mut matrix);
24-
Transform::from_ui_matrix(&matrix)
22+
let mut matrix = mem::MaybeUninit::uninit();
23+
ui_sys::uiDrawMatrixSetIdentity(matrix.as_mut_ptr());
24+
Transform::from_ui_matrix(&matrix.assume_init())
2525
}
2626
}
2727

0 commit comments

Comments
 (0)