1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-05 02:54:10 +02:00

fix some more overflow panics

This commit is contained in:
Robin Appelman 2020-01-20 21:07:32 +01:00
commit 66d568a65f
3 changed files with 3 additions and 4 deletions

View file

@ -483,7 +483,7 @@ impl SendPropValue {
.ok_or(MalformedSendPropDefinitionError::UnsizedFloat)?;
let raw: u32 = stream.read_int(bit_count as usize)?;
// is this -1 correct?, it is consistent with the js version but seems weird
let percentage = (raw as f32) / ((1 << bit_count) as f32 - 1.0);
let percentage = (raw as f32) / ((1i32.wrapping_shl(bit_count)) as f32 - 1.0);
Ok(low + ((high - low) * percentage))
}
}