Skip to content

Commit b955b7d

Browse files
authored
fix: Avoid overflow when computing FoR's difference of min and max (#2549)
1 parent 4678ca3 commit b955b7d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

vortex-btrblocks/src/integer/stats.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ impl ErasedStats {
7373
ErasedStats::U16(x) => (x.max - x.min) as u64,
7474
ErasedStats::U32(x) => (x.max - x.min) as u64,
7575
ErasedStats::U64(x) => x.max - x.min,
76-
ErasedStats::I8(x) => (x.max - x.min) as u64,
77-
ErasedStats::I16(x) => (x.max - x.min) as u64,
78-
ErasedStats::I32(x) => (x.max - x.min) as u64,
79-
ErasedStats::I64(x) => (x.max - x.min) as u64,
76+
ErasedStats::I8(x) => (x.max as i16 - x.min as i16) as u64,
77+
ErasedStats::I16(x) => (x.max as i32 - x.min as i32) as u64,
78+
ErasedStats::I32(x) => (x.max as i64 - x.min as i64) as u64,
79+
ErasedStats::I64(x) => u64::try_from(x.max as i128 - x.min as i128)
80+
.vortex_expect("max minus min result bigger than u64"),
8081
}
8182
}
8283

0 commit comments

Comments
 (0)