From dd5459ce862dfe709b88f698a28e72b31be6fb7c Mon Sep 17 00:00:00 2001 From: Wei Li Date: Thu, 31 May 2018 17:29:12 +0000 Subject: Handle image mask continuous loading correctly When image mask doesn't need multi-steps to load, ContinueLoadMaskDIB() will return LoadState::kFail as result. For this case, the loading should continue as usual instead of aborting. BUG=pdfium:1087 Change-Id: I5c43a67e43469ac7febca4c0cf1faa96ee105206 Reviewed-on: https://pdfium-review.googlesource.com/33310 Reviewed-by: dsinclair Commit-Queue: Wei Li --- core/fpdfapi/render/cpdf_dibsource.cpp | 6 ++++-- .../render/fpdf_render_loadimage_embeddertest.cpp | 9 +++++++++ testing/resources/bug_1087.pdf | Bin 0 -> 1574 bytes 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 testing/resources/bug_1087.pdf diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp index 3a4ca02cc2..d1eba2e467 100644 --- a/core/fpdfapi/render/cpdf_dibsource.cpp +++ b/core/fpdfapi/render/cpdf_dibsource.cpp @@ -323,8 +323,10 @@ CPDF_DIBSource::LoadState CPDF_DIBSource::ContinueLoadDIBSource( LoadState iContinueStatus = LoadState::kSuccess; if (m_bHasMask) { - iContinueStatus = ContinueLoadMaskDIB(pPause); - m_Status = LoadState::kContinue; + if (ContinueLoadMaskDIB(pPause) == LoadState::kContinue) { + iContinueStatus = LoadState::kContinue; + m_Status = LoadState::kContinue; + } } if (iContinueStatus == LoadState::kContinue) return LoadState::kContinue; diff --git a/core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp b/core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp index 5103d787bd..e3bd297afb 100644 --- a/core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp +++ b/core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp @@ -40,3 +40,12 @@ TEST_F(FPDFRenderLoadImageEmbeddertest, Bug_603518) { CompareBitmap(bitmap.get(), 749, 749, "b9e75190cdc5edf0069a408744ca07dc"); UnloadPage(page); } + +TEST_F(FPDFRenderLoadImageEmbeddertest, Bug_1087) { + EXPECT_TRUE(OpenDocument("bug_1087.pdf")); + FPDF_PAGE page = LoadPage(0); + ASSERT_TRUE(page); + ScopedFPDFBitmap bitmap = RenderLoadedPage(page); + CompareBitmap(bitmap.get(), 548, 238, "2aac40afa121feb0f38883cb04a55001"); + UnloadPage(page); +} diff --git a/testing/resources/bug_1087.pdf b/testing/resources/bug_1087.pdf new file mode 100644 index 0000000000..73bc682c4a Binary files /dev/null and b/testing/resources/bug_1087.pdf differ -- cgit v1.2.3