mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-05 16:12:13 +00:00
Improve testing and error handling around operating before processing
This commit is contained in:
parent
ac17308cf6
commit
720ce9e8f3
@ -113,7 +113,9 @@ extern "C" {
|
|||||||
char const* qpdf_get_qpdf_version();
|
char const* qpdf_get_qpdf_version();
|
||||||
|
|
||||||
/* Returns dynamically allocated qpdf_data pointer; must be freed
|
/* Returns dynamically allocated qpdf_data pointer; must be freed
|
||||||
* by calling qpdf_cleanup.
|
* by calling qpdf_cleanup. You must call qpdf_read or one of the
|
||||||
|
* other qpdf_read_* functions before calling any function that
|
||||||
|
* would need to operate on the PDF file.
|
||||||
*/
|
*/
|
||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
qpdf_data qpdf_init();
|
qpdf_data qpdf_init();
|
||||||
|
@ -85,8 +85,10 @@ class InvalidInputSource: public InputSource
|
|||||||
private:
|
private:
|
||||||
void throwException()
|
void throwException()
|
||||||
{
|
{
|
||||||
throw std::runtime_error(
|
throw std::logic_error(
|
||||||
"QPDF operation attempted after closing input source");
|
"QPDF operation attempted on a QPDF object with no input source."
|
||||||
|
" QPDF operations are invalid before processFile (or another"
|
||||||
|
" process method) or after closeInputSource");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
WARNING: closed input source: object 1/0: error reading object: QPDF operation attempted after closing input source
|
getRoot: attempted to dereference an uninitialized QPDFObjectHandle
|
||||||
|
WARNING: closed input source: object 1/0: error reading object: QPDF operation attempted on a QPDF object with no input source. QPDF operations are invalid before processFile (or another process method) or after closeInputSource
|
||||||
closed input source: unable to find /Root dictionary
|
closed input source: unable to find /Root dictionary
|
||||||
|
@ -2715,6 +2715,16 @@ void runtest(int n, char const* filename1, char const* arg2)
|
|||||||
}
|
}
|
||||||
else if (n == 73)
|
else if (n == 73)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QPDF pdf2;
|
||||||
|
pdf2.getRoot();
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
std::cerr << "getRoot: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
pdf.closeInputSource();
|
pdf.closeInputSource();
|
||||||
pdf.getRoot().getKey("/Pages").unparseResolved();
|
pdf.getRoot().getKey("/Pages").unparseResolved();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user