From 0b8f2fee646c53b3e6eb1fbbf13211f286e8cb82 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 29 Sep 2015 12:26:30 -0700 Subject: Merge to M46: Fix blank page issue caused by too strict correction on bpc For bit per component (bpc), PDF spec mentions that a RunLengthDecode or DCTDecode filter shall always deliver 8-bit samples. However, some PDF files don't follow this rule. We can find that filter is RunLengthDecode but bpc is 1 in the provided test file. In this case, pdfium will correct bpc to 8 but the actual bpc is 1. It causes a failure because the data is much more than the expected. To handle this case, pdfium doesn't correct bpc to 8 when the original bpc is 1. BUG=512557 R=tsepez@chromium.org TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1328213002 . (cherry picked from commit 3500e90e9e42fa84dd6f07da16cfcf197ec98283) Review URL: https://codereview.chromium.org/1377943002 . --- core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp | 7 +++++-- testing/resources/pixel/bug_512557.in | Bin 0 -> 1329 bytes testing/resources/pixel/bug_512557_expected.pdf.0.png | Bin 0 -> 185 bytes 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 testing/resources/pixel/bug_512557.in create mode 100644 testing/resources/pixel/bug_512557_expected.pdf.0.png diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index 8a614810df..834623dd1f 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -965,8 +965,11 @@ void CPDF_DIBSource::ValidateDictParam() { m_bpc = 1; m_nComponents = 1; } - if (filter == FX_BSTRC("RunLengthDecode") || - filter == FX_BSTRC("DCTDecode")) { + if (filter == FX_BSTRC("RunLengthDecode")) { + if (m_bpc != 1) { + m_bpc = 8; + } + } else if (filter == FX_BSTRC("DCTDecode")) { m_bpc = 8; } } else if (pFilter->GetType() == PDFOBJ_ARRAY) { diff --git a/testing/resources/pixel/bug_512557.in b/testing/resources/pixel/bug_512557.in new file mode 100644 index 0000000000..5f353341d5 Binary files /dev/null and b/testing/resources/pixel/bug_512557.in differ diff --git a/testing/resources/pixel/bug_512557_expected.pdf.0.png b/testing/resources/pixel/bug_512557_expected.pdf.0.png new file mode 100644 index 0000000000..66c73aebea Binary files /dev/null and b/testing/resources/pixel/bug_512557_expected.pdf.0.png differ -- cgit v1.2.3