From 5937d0d03793caf73c8bb795ac06684596790e82 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 11 Nov 2016 12:05:27 -0800 Subject: 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 --- core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'core/fpdfapi') 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, -- cgit v1.2.3