bspeice/dtparse

panicked at 'index out of bounds: the len is 5 but the index is 5'

Closed this issue · 3 comments

Input
)6..

Output

thread 'main' panicked at 'index out of bounds: the len is 5 but the index is 5', /home/xsh/.cargo/registry/src/github.com-1ecc6299db9ec823/dtparse-1.2.0/src/lib.rs:1134:60
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: std::panicking::rust_panic_with_hook
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::panicking::panic_bounds_check
   9: dtparse::Parser::parse_numeric_token
             at /home/xsh/.cargo/registry/src/github.com-1ecc6299db9ec823/dtparse-1.2.0/src/lib.rs:1134
  10: dtparse::Parser::parse_with_tokens
             at /home/xsh/.cargo/registry/src/github.com-1ecc6299db9ec823/dtparse-1.2.0/src/lib.rs:771
  11: dtparse::Parser::parse
             at /home/xsh/.cargo/registry/src/github.com-1ecc6299db9ec823/dtparse-1.2.0/src/lib.rs:719

Expect
return error properly instead of panic

I just ran this against dtparse in master, and for the input:

)6..

...I get Err(UnrecognizedToken(")")). Is there any special binary formatting that may not be preserved in the ticket?

in.zip
Here is the original file. You can try reading and parsing :) @bspeice

Added a test, this no longer panics.