Skip to content

Commit

Permalink
fix: Avoid overflow when computing FoR's difference of min and max (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 authored Feb 27, 2025
1 parent 4678ca3 commit b955b7d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions vortex-btrblocks/src/integer/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ impl ErasedStats {
ErasedStats::U16(x) => (x.max - x.min) as u64,
ErasedStats::U32(x) => (x.max - x.min) as u64,
ErasedStats::U64(x) => x.max - x.min,
ErasedStats::I8(x) => (x.max - x.min) as u64,
ErasedStats::I16(x) => (x.max - x.min) as u64,
ErasedStats::I32(x) => (x.max - x.min) as u64,
ErasedStats::I64(x) => (x.max - x.min) as u64,
ErasedStats::I8(x) => (x.max as i16 - x.min as i16) as u64,
ErasedStats::I16(x) => (x.max as i32 - x.min as i32) as u64,
ErasedStats::I32(x) => (x.max as i64 - x.min as i64) as u64,
ErasedStats::I64(x) => u64::try_from(x.max as i128 - x.min as i128)
.vortex_expect("max minus min result bigger than u64"),
}
}

Expand Down

0 comments on commit b955b7d

Please sign in to comment.