summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorJun Fang <jun_fang@foxitsoftware.com>2014-08-22 17:04:29 -0700
committerJun Fang <jun_fang@foxitsoftware.com>2014-08-22 17:04:29 -0700
commitaeacba4a612a0a35b3e834d778716968c661f3ec (patch)
treeed71f0098e1388a9a74c176fadb9fb53fd1f1984 /samples
parent02132dcdf97674c223d9a3566c89df9f57029d5c (diff)
downloadpdfium-aeacba4a612a0a35b3e834d778716968c661f3ec.tar.xz
Fix a hang issue due to inconsistent page number in the test file
Pdfium reads the page number from the field of '/Count' but it can't load the number assigned by this field due to the damaged data. Add a check to ensure that the required page should be one of loaded pages. BUG=406090 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/477873003
Diffstat (limited to 'samples')
-rw-r--r--samples/pdfium_test.cc11
1 files changed, 10 insertions, 1 deletions
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[]) {