Skip to content

Commit

Permalink
Fix UB caused by unaligned read
Browse files Browse the repository at this point in the history
  • Loading branch information
capickett committed Feb 14, 2024
1 parent ceb2a9e commit 57c7f12
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/structures/003_enclosure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ fn read_bytes<T: Copy>(data: &mut &[u8]) -> Option<T> {
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::<T>()..];
Some(value)
}
Expand Down

0 comments on commit 57c7f12

Please sign in to comment.