From 57c7f122b0765ca470aa215422ed698ef57c5427 Mon Sep 17 00:00:00 2001 From: Cameron Pickett Date: Wed, 14 Feb 2024 11:30:28 -0800 Subject: [PATCH] Fix UB caused by unaligned read --- src/structures/003_enclosure.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/003_enclosure.rs b/src/structures/003_enclosure.rs index d944ace..46da7d2 100644 --- a/src/structures/003_enclosure.rs +++ b/src/structures/003_enclosure.rs @@ -506,7 +506,7 @@ fn read_bytes(data: &mut &[u8]) -> Option { return None; } - let value = unsafe { core::ptr::read((*data).as_ptr() as *const T) }; + let value = unsafe { core::ptr::read_unaligned((*data).as_ptr() as *const T) }; *data = &data[core::mem::size_of::()..]; Some(value) }