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 1
1
[package ]
2
2
name = " json"
3
- version = " 0.11.5 "
3
+ version = " 0.11.6 "
4
4
authors = [" Maciej Hirsz <maciej.hirsz@gmail.com>" ]
5
5
description = " JSON implementation in Rust"
6
6
repository = " 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 {
281
281
// quite handy as the only number that can begin with zero, has to have
282
282
// a zero mantissa. Leading zeroes are illegal in JSON!
283
283
( $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
+ }
288
292
} )
289
293
}
290
294
@@ -383,6 +387,8 @@ impl<'a> Parser<'a> {
383
387
// is virtually irrelevant.
384
388
#[ inline( always) ]
385
389
fn read_byte ( & mut self ) -> u8 {
390
+ debug_assert ! ( self . index < self . length, "Reading out of bounds" ) ;
391
+
386
392
unsafe { * self . byte_ptr . offset ( self . index as isize ) }
387
393
}
388
394
Original file line number Diff line number Diff line change @@ -327,3 +327,9 @@ fn does_not_panic_on_single_unicode_char() {
327
327
assert ! ( parse( & string) . is_err( ) ) ;
328
328
}
329
329
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