Skip to content

Commit

Permalink
Fix integer overflow handling
Browse files Browse the repository at this point in the history
  • Loading branch information
DelSkayn committed Aug 15, 2024
1 parent baf97fc commit 1900b53
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/implementations/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ macro_rules! impl_revisioned_int {
where
Self: Sized,
{
decode_u64(reader).map(|x| x as $ty)
decode_u64(reader).and_then(|x| x.try_into().map_err(|_| Error::IntegerOverflow))
}

fn revision() -> u16 {
Expand All @@ -263,7 +263,8 @@ macro_rules! impl_revisioned_signed_int {
where
Self: Sized,
{
decode_u64(reader).map(|x| gazgiz_64(x) as $ty)
decode_u64(reader)
.and_then(|x| gazgiz_64(x).try_into().map_err(|_| Error::IntegerOverflow))
}

fn revision() -> u16 {
Expand Down

0 comments on commit 1900b53

Please sign in to comment.