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

Panic when opening pdf file #287

Closed
qarmin opened this issue Jul 21, 2024 · 0 comments · Fixed by #299
Closed

Panic when opening pdf file #287

qarmin opened this issue Jul 21, 2024 · 0 comments · Fixed by #299
Labels

Comments

@qarmin
Copy link

qarmin commented Jul 21, 2024

Code

fn check_file(file_path: &str) {
    match Document::load(file_path) {
        Ok(mut document) => {
            let pages = document.get_pages();

            let mut doc_clone = document.clone();
            doc_clone.decompress();

            for (i, _) in pages.iter().enumerate() {
                let page_number = (i + 1) as u32;
                let _text = document.extract_text(&[page_number]);
            }

            document.save_to(&mut Cursor::new(Vec::new())).unwrap();
        }
        Err(err) => {
            eprintln!("Error reading PDF contents: {}", err)
        }
    }
}

File - compressed.zip

thread '<unnamed>' panicked at /home/runner/.cargo/git/checkouts/lopdf-0013854ec52a6141/2cf9f98/src/object_stream.rs:43:63:
range start index 3026 out of range for slice of length 3016
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::slice::index::slice_start_index_len_fail
   3: rayon::iter::plumbing::Producer::fold_with
   4: rayon::iter::plumbing::bridge_producer_consumer::helper
   5: rayon_core::join::join_context::{{closure}}
   6: rayon::iter::plumbing::bridge_producer_consumer::helper
   7: rayon_core::join::join_context::{{closure}}
   8: rayon::iter::plumbing::bridge_producer_consumer::helper
   9: rayon_core::join::join_context::{{closure}}
  10: rayon::iter::plumbing::bridge_producer_consumer::helper
  11: rayon::iter::extend::<impl rayon::iter::ParallelExtend<(K,V)> for alloc::collections::btree::map::BTreeMap<K,V>>::par_extend
  12: rayon::iter::from_par_iter::collect_extended
  13: lopdf::object_stream::ObjectStream::new
  14: lopdf::reader::Reader::read::{{closure}}
  15: rayon::iter::plumbing::Folder::consume_iter
  16: rayon::iter::plumbing::bridge_producer_consumer::helper
  17: rayon_core::join::join_context::{{closure}}
  18: rayon_core::registry::in_worker
  19: rayon::iter::plumbing::bridge_producer_consumer::helper
  20: rayon_core::join::join_context::{{closure}}
  21: rayon_core::registry::in_worker
  22: rayon::iter::plumbing::bridge_producer_consumer::helper
  23: rayon_core::join::join_context::{{closure}}
  24: rayon_core::registry::in_worker
  25: rayon::iter::plumbing::bridge_producer_consumer::helper
  26: rayon_core::join::join_context::{{closure}}
  27: rayon_core::registry::in_worker
  28: rayon::iter::plumbing::bridge_producer_consumer::helper
  29: <rayon_core::job::StackJob<L,F,R> as rayon_core::job::Job>::execute
  30: rayon_core::registry::WorkerThread::wait_until_cold
  31: rayon_core::registry::ThreadBuilder::run
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

##### Automatic Fuzzer note, output status "Some(101)", output signal "None"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants