Merge pull request #493 from dtolnay/overflow

Fix overflow on i32::min_value() as exponent
This commit is contained in:
David Tolnay 2018-10-03 22:38:05 -07:00 committed by GitHub
commit cb443cef63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -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;

View File

@ -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,