summaryrefslogtreecommitdiff
path: root/core/fpdfapi/edit
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-11 12:05:27 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-11 12:05:27 -0800
commit5937d0d03793caf73c8bb795ac06684596790e82 (patch)
treeb20a4b1d197f6199a318455c83390dde2c8bca92 /core/fpdfapi/edit
parenta0d3231037816d3f0e377e9c57a2bfaa1372e151 (diff)
downloadpdfium-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
Diffstat (limited to 'core/fpdfapi/edit')
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp23
1 files changed, 14 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,