Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reader panics after reading 1 record saying 'byte index 4 is out of bounds of /' #51

Open
debugger22 opened this issue Mar 5, 2023 · 1 comment

Comments

@debugger22
Copy link

Code:

use dbase;

fn main() {
    let mut reader = dbase::Reader::from_path("SAL.dbf").unwrap();
    for record_result in reader.iter_records() {
        if let Ok(record) = record_result {
            for (name, value) in record {
                match name.as_str() {
                    "BILLNO" => match value {
                        dbase::FieldValue::Character(Some(data)) => {
                            println!("{}", data);
                        }
                        _ => {}
                    },
                    _ => {}
                }
            }
        }
    }
}

Rust version: rustc 1.67.1 (d5a82bbd2 2023-02-07)
Stacktrace

thread 'main' panicked at 'byte index 4 is out of bounds of `/`', /home/debugger22/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/dbase-0.3.0/src/record/field.rs:487:20
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panicking.rs:64:14
   2: core::str::slice_error_fail_rt
   3: core::str::slice_error_fail
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/str/mod.rs:86:9
   4: core::str::traits::<impl core::slice::index::SliceIndex<str> for core::ops::range::Range<usize>>::index
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/str/traits.rs:218:21
   5: core::str::traits::<impl core::ops::index::Index<I> for str>::index
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/str/traits.rs:65:9
   6: <dbase::record::field::Date as core::str::traits::FromStr>::from_str
             at /home/debugger22/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/dbase-0.3.0/src/record/field.rs:487:20
   7: core::str::<impl str>::parse
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/str/mod.rs:2351:9
   8: dbase::record::field::FieldValue::read_from
             at /home/debugger22/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/dbase-0.3.0/src/record/field.rs:312:43
   9: dbase::reading::FieldIterator<T>::read_field
             at /home/debugger22/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/dbase-0.3.0/src/reading.rs:548:15
  10: dbase::reading::FieldIterator<T>::read_next_field_impl
             at /home/debugger22/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/dbase-0.3.0/src/reading.rs:429:29
  11: dbase::reading::FieldIterator<T>::read_next_field
             at /home/debugger22/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/dbase-0.3.0/src/reading.rs:438:9
  12: <dbase::reading::FieldIterator<T> as core::iter::traits::iterator::Iterator>::next
             at /home/debugger22/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/dbase-0.3.0/src/reading.rs:567:15
  13: <&mut I as core::iter::traits::iterator::Iterator>::next
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/iter/traits/iterator.rs:3878:9
  14: <dbase::reading::Record as dbase::reading::ReadableRecord>::read_using
             at /home/debugger22/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/dbase-0.3.0/src/reading.rs:54:23
  15: <dbase::reading::RecordIterator<T,R> as core::iter::traits::iterator::Iterator>::next
             at /home/debugger22/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/dbase-0.3.0/src/reading.rs:611:26
  16: test_dbf::main
             at ./src/main.rs:5:26
  17: core::ops::function::FnOnce::call_once
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@tmontaigu
Copy link
Owner

Is the file that causes this publicly available ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants