@@ -451,30 +451,33 @@ impl<'de, R: Read<'de>> Deserializer<R> {
451
451
& mut self ,
452
452
positive : bool ,
453
453
mut significand : u64 ,
454
- mut exponent : i32 ,
454
+ exponent_before_decimal_point : i32 ,
455
455
) -> Result < f64 > {
456
456
self . eat_char ( ) ;
457
457
458
+ let mut exponent_after_decimal_point = 0 ;
458
459
while let c @ b'0' ..=b'9' = tri ! ( self . peek_or_null( ) ) {
459
460
let digit = ( c - b'0' ) as u64 ;
460
461
461
462
if overflow ! ( significand * 10 + digit, u64 :: max_value( ) ) {
463
+ let exponent = exponent_before_decimal_point + exponent_after_decimal_point;
462
464
return self . parse_decimal_overflow ( positive, significand, exponent) ;
463
465
}
464
466
465
467
self . eat_char ( ) ;
466
468
significand = significand * 10 + digit;
467
- exponent -= 1 ;
469
+ exponent_after_decimal_point -= 1 ;
468
470
}
469
471
470
472
// Error if there is not at least one digit after the decimal point.
471
- if exponent == 0 {
473
+ if exponent_after_decimal_point == 0 {
472
474
match tri ! ( self . peek( ) ) {
473
475
Some ( _) => return Err ( self . peek_error ( ErrorCode :: InvalidNumber ) ) ,
474
476
None => return Err ( self . peek_error ( ErrorCode :: EofWhileParsingValue ) ) ,
475
477
}
476
478
}
477
479
480
+ let exponent = exponent_before_decimal_point + exponent_after_decimal_point;
478
481
match tri ! ( self . peek_or_null( ) ) {
479
482
b'e' | b'E' => self . parse_exponent ( positive, significand, exponent) ,
480
483
_ => self . f64_from_parts ( positive, significand, exponent) ,
0 commit comments