mirror of
https://github.com/serde-rs/json.git
synced 2025-10-01 06:51:58 +00:00
Fix overflow on i32::min_value() as exponent
This commit is contained in:
parent
805f394f8b
commit
2161f0540f
@ -676,7 +676,7 @@ impl<'de, R: Read<'de>> Deserializer<R> {
|
||||
) -> Result<f64> {
|
||||
let mut f = significand as f64;
|
||||
loop {
|
||||
match POW10.get(exponent.abs() as usize) {
|
||||
match POW10.get(exponent.wrapping_abs() as usize) {
|
||||
Some(&pow) => {
|
||||
if exponent >= 0 {
|
||||
f *= pow;
|
||||
|
@ -860,6 +860,7 @@ fn test_parse_f64() {
|
||||
("0.00e00", 0.0),
|
||||
("0.00e+00", 0.0),
|
||||
("0.00e-00", 0.0),
|
||||
("3.5E-2147483647", 0.0),
|
||||
(
|
||||
&format!("{}", (i64::MIN as f64) - 1.0),
|
||||
(i64::MIN as f64) - 1.0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user