Do all checks first in CPDF_PageContentGenerator::ProcessImage().
Avoid starting to write to the output stream, only to stop half way
through and abort.
Change-Id: I191075455412e99a48184f326c83b6a5efd2c6ee
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/81989
Reviewed-by: Hui Yingst <nigi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
index e288828..ad7de5f 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
@@ -302,7 +302,6 @@
(pImageObj->matrix().c == 0 && pImageObj->matrix().d == 0)) {
return;
}
- *buf << "q " << pImageObj->matrix() << " cm ";
RetainPtr<CPDF_Image> pImage = pImageObj->GetImage();
if (pImage->IsInline())
@@ -312,6 +311,8 @@
if (!pStream)
return;
+ *buf << "q " << pImageObj->matrix() << " cm ";
+
bool bWasInline = pStream->IsInline();
if (bWasInline)
pImage->ConvertStreamToIndirectObject();