summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdf_flatten.cpp14
-rw-r--r--fpdfsdk/fpdfsave.cpp10
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp4
3 files changed, 12 insertions, 16 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;
diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp
index 6894f8c2ed..004c921a52 100644
--- a/fpdfsdk/fpdfsave.cpp
+++ b/fpdfsdk/fpdfsave.cpp
@@ -137,12 +137,10 @@ bool SaveXFADocumentData(
// template
if (iTemplate > -1) {
CPDF_Stream* pTemplateStream = pArray->GetStreamAt(iTemplate);
- CPDF_StreamAcc streamAcc;
- streamAcc.LoadAllData(pTemplateStream);
- uint8_t* pData = (uint8_t*)streamAcc.GetData();
- uint32_t dwSize2 = streamAcc.GetSize();
- CFX_RetainPtr<IFX_SeekableStream> pTemplate =
- IFX_MemoryStream::Create(pData, dwSize2);
+ auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pTemplateStream);
+ pAcc->LoadAllData();
+ CFX_RetainPtr<IFX_SeekableStream> pTemplate = IFX_MemoryStream::Create(
+ const_cast<uint8_t*>(pAcc->GetData()), pAcc->GetSize());
pChecksum->UpdateChecksum(pTemplate);
}
CPDF_Stream* pFormStream = nullptr;
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index 4c8591e2eb..bd16f43ffc 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -497,8 +497,8 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc,
fileWrite->WriteBlock(content.c_str(), fileWrite->GetSize(),
content.GetLength());
}
- auto pAcc = pdfium::MakeUnique<CPDF_StreamAcc>();
- pAcc->LoadAllData(pStream);
+ auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream);
+ pAcc->LoadAllData();
fileWrite->WriteBlock(pAcc->GetData(), fileWrite->GetSize(),
pAcc->GetSize());
}