File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " json"
3- version = " 0.11.5 "
3+ version = " 0.11.6 "
44authors = [" Maciej Hirsz <maciej.hirsz@gmail.com>" ]
55description = " JSON implementation in Rust"
66repository = " https://github.com/maciejhirsz/json-rust"
Original file line number Diff line number Diff line change @@ -281,10 +281,14 @@ macro_rules! allow_number_extensions {
281281 // quite handy as the only number that can begin with zero, has to have
282282 // a zero mantissa. Leading zeroes are illegal in JSON!
283283 ( $parser: ident) => ( {
284- let mut num = 0 ;
285- let mut e = 0 ;
286- let ch = $parser. read_byte( ) ;
287- allow_number_extensions!( $parser, num, e, ch)
284+ if $parser. is_eof( ) {
285+ 0 . into( )
286+ } else {
287+ let mut num = 0 ;
288+ let mut e = 0 ;
289+ let ch = $parser. read_byte( ) ;
290+ allow_number_extensions!( $parser, num, e, ch)
291+ }
288292 } )
289293}
290294
@@ -383,6 +387,8 @@ impl<'a> Parser<'a> {
383387 // is virtually irrelevant.
384388 #[ inline( always) ]
385389 fn read_byte ( & mut self ) -> u8 {
390+ debug_assert ! ( self . index < self . length, "Reading out of bounds" ) ;
391+
386392 unsafe { * self . byte_ptr . offset ( self . index as isize ) }
387393 }
388394
Original file line number Diff line number Diff line change @@ -327,3 +327,9 @@ fn does_not_panic_on_single_unicode_char() {
327327 assert ! ( parse( & string) . is_err( ) ) ;
328328}
329329
330+ #[ test]
331+ fn does_not_panic_on_single_zero ( ) {
332+ let source = "0" ;
333+
334+ parse ( source) . unwrap ( ) ;
335+ }
You can’t perform that action at this time.
0 commit comments