File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -496,7 +496,10 @@ impl<'de, R: Read<'de>> Deserializer<R> {
496
496
}
497
497
498
498
if !at_least_one_digit {
499
- return Err ( self . peek_error ( ErrorCode :: InvalidNumber ) ) ;
499
+ match try!( self . peek ( ) ) {
500
+ Some ( _) => return Err ( self . peek_error ( ErrorCode :: InvalidNumber ) ) ,
501
+ None => return Err ( self . peek_error ( ErrorCode :: EofWhileParsingValue ) ) ,
502
+ }
500
503
}
501
504
502
505
match try!( self . peek_or_null ( ) ) {
@@ -680,7 +683,10 @@ impl<'de, R: Read<'de>> Deserializer<R> {
680
683
}
681
684
682
685
if !at_least_one_digit {
683
- return Err ( self . peek_error ( ErrorCode :: InvalidNumber ) ) ;
686
+ match try!( self . peek ( ) ) {
687
+ Some ( _) => return Err ( self . peek_error ( ErrorCode :: InvalidNumber ) ) ,
688
+ None => return Err ( self . peek_error ( ErrorCode :: EofWhileParsingValue ) ) ,
689
+ }
684
690
}
685
691
686
692
match try!( self . peek_or_null ( ) ) {
Original file line number Diff line number Diff line change @@ -81,6 +81,16 @@ fn test_json_stream_truncated() {
81
81
} ) ;
82
82
}
83
83
84
+ #[ test]
85
+ fn test_json_stream_truncated_decimal ( ) {
86
+ let data = "{\" x\" :4." ;
87
+
88
+ test_stream ! ( data, Value , |stream| {
89
+ assert!( stream. next( ) . unwrap( ) . unwrap_err( ) . is_eof( ) ) ;
90
+ assert_eq!( stream. byte_offset( ) , 0 ) ;
91
+ } ) ;
92
+ }
93
+
84
94
#[ test]
85
95
fn test_json_stream_empty ( ) {
86
96
let data = "" ;
Original file line number Diff line number Diff line change @@ -741,7 +741,7 @@ fn test_parse_number_errors() {
741
741
( "00" , "invalid number at line 1 column 2" ) ,
742
742
( "0x80" , "trailing characters at line 1 column 2" ) ,
743
743
( "\\ 0" , "expected value at line 1 column 1" ) ,
744
- ( "1." , "invalid number at line 1 column 2" ) ,
744
+ ( "1." , "EOF while parsing a value at line 1 column 2" ) ,
745
745
( "1.a" , "invalid number at line 1 column 3" ) ,
746
746
( "1.e1" , "invalid number at line 1 column 3" ) ,
747
747
( "1e" , "invalid number at line 1 column 2" ) ,
You can’t perform that action at this time.
0 commit comments