pdftops: Added NULL check and clean-up to the pdf_pages() function in pdf.cxx
@@ -93,13 +93,18 @@ extern "C" void pdf_free(pdf_t *pdf)
int pdf_pages(const char *filename)
{
QPDF *pdf = new QPDF();
+ if (pdf) {
try{
pdf->processFile(filename);
} catch(...) {
+ pdf_free(pdf);
return -1;
}
int pages = (pdf->getAllPages()).size();
+ pdf_free(pdf);
return pages;
+ } else
+ return -1;
}
