Fix unsound transmute

This commit is contained in:
Arthur Beck 2025-02-25 17:35:24 -06:00
parent 533a7b6c52
commit aefc8b032c
Signed by: ArthurB
GPG key ID: ACE3D14F5CEF14BF

View file

@ -32,6 +32,7 @@ pub struct RawPCScreenFont {
} }
/// The glyph type for [PCScreenFont]. /// The glyph type for [PCScreenFont].
#[derive(Clone, Copy)]
pub struct Glyph { pub struct Glyph {
/// The size of this glyph. /// The size of this glyph.
pub len: u32, pub len: u32,
@ -113,7 +114,7 @@ pub fn parse_pc_screen_font(data: RawPCScreenFont) -> Result<PCScreenFont, crate
flags: data.flags, flags: data.flags,
height: data.height, height: data.height,
width: data.width, width: data.width,
glyphs: core::mem::transmute(data.glyphs), glyphs: Vec::from(core::mem::transmute::<&[u8], &[Glyph]>(data.glyphs.as_slice())),
unitable: Some(unitable), unitable: Some(unitable),
}; };
return Ok(out); return Ok(out);
@ -124,7 +125,7 @@ pub fn parse_pc_screen_font(data: RawPCScreenFont) -> Result<PCScreenFont, crate
flags: data.flags, flags: data.flags,
height: data.height, height: data.height,
width: data.width, width: data.width,
glyphs: core::mem::transmute(data.glyphs), glyphs: Vec::from(core::mem::transmute::<&[u8], &[Glyph]>(data.glyphs.as_slice())),
unitable: None, unitable: None,
}; };
Ok(out) Ok(out)