summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_flatten.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-04 14:37:18 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-04 21:48:48 +0000
commitafd0d1f488ea55da545b3310fd8f22e45522a695 (patch)
tree89136eba4669421b6f828edb9f3d69ee558110d0 /fpdfsdk/fpdf_flatten.cpp
parent4f8b044b95dc282959dfe41453e2a9c1ec7e9354 (diff)
downloadpdfium-afd0d1f488ea55da545b3310fd8f22e45522a695.tar.xz
RefCount CPDF_StreamAcc all the time.
Pass stream argument to constructor; it feels like a stream accessor should always be made from a stream rather than passing one in after the fact. Change-Id: Iaa46cb37677b81f0170f5d39bab76ad38ea4af44 Reviewed-on: https://pdfium-review.googlesource.com/3620 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_flatten.cpp')
-rw-r--r--fpdfsdk/fpdf_flatten.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp
index 8e181eb380..31b838cd94 100644
--- a/fpdfsdk/fpdf_flatten.cpp
+++ b/fpdfsdk/fpdf_flatten.cpp
@@ -204,11 +204,11 @@ void SetPageContents(const CFX_ByteString& key,
pPage->ConvertToIndirectObjectFor("Contents", pDocument);
if (!pContentsArray) {
pContentsArray = pDocument->NewIndirect<CPDF_Array>();
- CPDF_StreamAcc acc;
- acc.LoadAllData(pContentsStream);
+ auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pContentsStream);
+ pAcc->LoadAllData();
CFX_ByteString sStream = "q\n";
CFX_ByteString sBody =
- CFX_ByteString((const char*)acc.GetData(), acc.GetSize());
+ CFX_ByteString((const char*)pAcc->GetData(), pAcc->GetSize());
sStream = sStream + sBody + "\nQ";
pContentsStream->SetData(sStream.raw_str(), sStream.GetLength());
pContentsArray->AddNew<CPDF_Reference>(pDocument,
@@ -402,11 +402,9 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
pXObject->SetNewFor<CPDF_Reference>(sFormName, pDocument,
pObj->GetObjNum());
- CPDF_StreamAcc acc;
- acc.LoadAllData(pNewXObject);
-
- const uint8_t* pData = acc.GetData();
- CFX_ByteString sStream(pData, acc.GetSize());
+ auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pNewXObject);
+ pAcc->LoadAllData();
+ CFX_ByteString sStream(pAcc->GetData(), pAcc->GetSize());
CFX_Matrix matrix = pAPDic->GetMatrixFor("Matrix");
if (matrix.IsIdentity()) {
matrix.a = 1.0f;