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

fixed crashing debug output when font has no name #29

Merged
merged 1 commit into from
Oct 26, 2021

Conversation

Grollicus
Copy link
Contributor

I had a pdf document that was crashing like this:


thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: DictKey', $home/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/pdf-extract-0.6.3/src/lib.rs:470:62
stack backtrace:
   0: rust_begin_unwind
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/core/src/panicking.rs:101:14
   2: core::result::unwrap_failed
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/core/src/result.rs:1617:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/core/src/result.rs:1299:23
   4: pdf_extract::PdfSimpleFont::new
             at $home/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/pdf-extract-0.6.3/src/lib.rs:470:40
   5: pdf_extract::make_font
             at $home/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/pdf-extract-0.6.3/src/lib.rs:323:17
   6: pdf_extract::Processor::process_stream::{{closure}}
             at $home/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/pdf-extract-0.6.3/src/lib.rs:1478:84
   7: std::collections::hash::map::Entry<K,V>::or_insert_with
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/std/src/collections/hash/map.rs:2345:43
   8: pdf_extract::Processor::process_stream
             at $home/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/pdf-extract-0.6.3/src/lib.rs:1478:32
   9: pdf_extract::output_doc
             at $home/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/pdf-extract-0.6.3/src/lib.rs:2029:9

Crashing was this line:

let name = pdf_to_utf8(encoding.get(b"Type").unwrap().as_name().unwrap());

Or more specifically encoding.get(b"Type").unwrap(). So, basically, no Type. As name is only used for debug output I think it can be safely removed?

@jrmuizel jrmuizel merged commit 85de236 into jrmuizel:master Oct 26, 2021
@Grollicus Grollicus deleted the fix/crashing_debug_output branch October 26, 2021 08:05
Bennett-Petzold added a commit to Bennett-Petzold/pdf-extract that referenced this pull request Apr 18, 2024
Same issue and change as PR jrmuizel#29
(jrmuizel#29), but the panicking
code was duplicated in PdfSimpleFont and the duplication wasn't caught
by the original PR.
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

Successfully merging this pull request may close these issues.

2 participants