From 5ab4c87e18f0b5933c693f4db311388313cf33a4 Mon Sep 17 00:00:00 2001 From: Nathan West <Lucretiel@users.noreply.github.com> Date: Fri, 27 Oct 2023 19:42:50 -0400 Subject: [PATCH] Get rid of UB with `uninitialized` Remove `uninitialized`, which always produces UB when used with integers --- write/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/write/src/lib.rs b/write/src/lib.rs index cede77d..2e1a1b7 100644 --- a/write/src/lib.rs +++ b/write/src/lib.rs @@ -32,7 +32,7 @@ pub trait uWrite { /// entire byte sequence was successfully written, and this method will not return until all /// data has been written or an error occurs. fn write_char(&mut self, c: char) -> Result<(), Self::Error> { - let mut buf: [u8; 4] = unsafe { uninitialized() }; + let mut buf = [0; 4]; self.write_str(c.encode_utf8(&mut buf)) } }