Skip to content

Commit 6b48fad

Browse files
committed
feat: return error when ptr not aligned
Signed-off-by: Woshiluo Luo <woshiluo.luo@outlook.com>
1 parent 3a0386f commit 6b48fad

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/de.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ where
6060
T: de::Deserialize<'de>,
6161
{
6262
// read header
63+
if (ptr as usize) & (ALIGN - 1) != 0 {
64+
return Err(Error::unaligned(ptr as usize));
65+
}
6366
let header = &*(ptr as *const Header);
6467
header.verify()?;
6568

0 commit comments

Comments
 (0)