diff options
author | tsepez <tsepez@chromium.org> | 2016-11-11 12:05:27 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-11 12:05:27 -0800 |
commit | 5937d0d03793caf73c8bb795ac06684596790e82 (patch) | |
tree | b20a4b1d197f6199a318455c83390dde2c8bca92 | |
parent | a0d3231037816d3f0e377e9c57a2bfaa1372e151 (diff) | |
download | pdfium-5937d0d03793caf73c8bb795ac06684596790e82.tar.xz |
Fix sevg above CPDF_PageContentGenerator::ProcessImage()
Adds a test to process an image for which a stream hasn't been
set.
BUG=660756
Review-Url: https://codereview.chromium.org/2494683007
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 23 | ||||
-rw-r--r-- | fpdfsdk/fpdfeditimg_unittest.cpp | 1 |
2 files changed, 15 insertions, 9 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index ad1ffaf687..20b4ea6eaf 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -94,16 +94,21 @@ void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf, return; } buf << "q " << pImageObj->m_Matrix << " cm "; + CPDF_Image* pImage = pImageObj->GetImage(); - if (!pImage->IsInline()) { - CPDF_Stream* pStream = pImage->GetStream(); - uint32_t dwSavedObjNum = pStream->GetObjNum(); - CFX_ByteString name = RealizeResource(pStream, "XObject"); - if (dwSavedObjNum == 0) { - pImageObj->SetUnownedImage(m_pDocument->GetPageData()->GetImage(pStream)); - } - buf << "/" << PDF_NameEncode(name) << " Do Q\n"; - } + if (pImage->IsInline()) + return; + + CPDF_Stream* pStream = pImage->GetStream(); + if (!pStream) + return; + + bool bWasInline = pStream->IsInline(); + CFX_ByteString name = RealizeResource(pStream, "XObject"); + if (bWasInline) + pImageObj->SetUnownedImage(m_pDocument->GetPageData()->GetImage(pStream)); + + buf << "/" << PDF_NameEncode(name) << " Do Q\n"; } void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, diff --git a/fpdfsdk/fpdfeditimg_unittest.cpp b/fpdfsdk/fpdfeditimg_unittest.cpp index a844e7ec71..ae4af2591e 100644 --- a/fpdfsdk/fpdfeditimg_unittest.cpp +++ b/fpdfsdk/fpdfeditimg_unittest.cpp @@ -43,6 +43,7 @@ TEST_F(PDFEditTest, NewImgeObj) { FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc); FPDFPage_InsertObject(page, page_image); EXPECT_EQ(1, FPDFPage_CountObject(page)); + EXPECT_TRUE(FPDFPage_GenerateContent(page)); FPDF_ClosePage(page); FPDF_CloseDocument(doc); |