diff options
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp | 2 | ||||
-rw-r--r-- | samples/pdfium_test.cc | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp index e0fd3bfaee..ce397d2a53 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp @@ -3989,7 +3989,7 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pP FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_PageNode &pageNodes, FX_INT32 iPage, FX_INT32 &iCount, IFX_DownloadHints* pHints) { FX_INT32 iSize = pageNodes.m_childNode.GetSize(); - if (!iSize) { + if (iSize <= 0 || iPage >= iSize) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; } diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index 72c8c5dcd1..7436e9d86c 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -304,8 +304,14 @@ void RenderPdf(const char* name, const char* pBuf, size_t len, FORM_DoDocumentJSAction(form); FORM_DoDocumentOpenAction(form); + size_t rendered_pages = 0; + size_t bad_pages = 0; for (int i = 0; i < page_count; ++i) { FPDF_PAGE page = FPDF_LoadPage(doc, i); + if (!page) { + bad_pages ++; + continue; + } FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page); FORM_OnAfterLoadPage(page, form); FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN); @@ -316,6 +322,8 @@ void RenderPdf(const char* name, const char* pBuf, size_t len, FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); + rendered_pages ++; + FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0); int stride = FPDFBitmap_GetStride(bitmap); const char* buffer = @@ -351,7 +359,8 @@ void RenderPdf(const char* name, const char* pBuf, size_t len, FPDF_CloseDocument(doc); FPDFAvail_Destroy(pdf_avail); - printf("Loaded, parsed and rendered %d pages.\n", page_count); + printf("Loaded, parsed and rendered %d pages.\n", rendered_pages); + printf("Skipped %d bad pages.\n", bad_pages); } int main(int argc, const char* argv[]) { |