Segfault on locked documents in c++ api
Submitted by Jeroen Ooms
Assigned to poppler-bugs
If the user enters an incorrect password when reading a protected pdf via document::load_from_raw_data() a message 'Incorrect password' is printed, however the function still returns a valid *document object.
This returned object has doc->is_locked() == true and several methods are still available such as:
doc->get_pdf_version() doc->info_date() doc->is_encrypted() doc->is_locked()
This is useful. What's not good is that calling any of the other methods will cause a segfault. For example:
doc->pages() doc->page_layout() doc->metadata() doc->create_pag() doc->fonts()
Calling any of these methods on a locked document should raise a c++ exception (e.g. "error: pdf file is locked") rather than crashing.