summaryrefslogtreecommitdiff
path: root/core/fpdfapi/edit
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 /core/fpdfapi/edit
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 'core/fpdfapi/edit')
-rw-r--r--core/fpdfapi/edit/fpdf_edit_create.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/core/fpdfapi/edit/fpdf_edit_create.cpp b/core/fpdfapi/edit/fpdf_edit_create.cpp
index 59d3de35a9..d08e4b5302 100644
--- a/core/fpdfapi/edit/fpdf_edit_create.cpp
+++ b/core/fpdfapi/edit/fpdf_edit_create.cpp
@@ -182,12 +182,12 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
return -1;
}
offset += 8;
- CPDF_StreamAcc acc;
- acc.LoadAllData(p, true);
- if (pFile->AppendBlock(acc.GetData(), acc.GetSize()) < 0) {
+ auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(p);
+ pAcc->LoadAllData(true);
+ if (pFile->AppendBlock(pAcc->GetData(), pAcc->GetSize()) < 0) {
return -1;
}
- offset += acc.GetSize();
+ offset += pAcc->GetSize();
if ((len = pFile->AppendString("\r\nendstream")) < 0) {
return -1;
}
@@ -411,7 +411,7 @@ class CPDF_FlateEncoder {
uint32_t m_dwSize;
CFX_MaybeOwned<uint8_t, FxFreeDeleter> m_pData;
CFX_MaybeOwned<CPDF_Dictionary> m_pDict;
- CPDF_StreamAcc m_Acc;
+ CFX_RetainPtr<CPDF_StreamAcc> m_pAcc;
};
void CPDF_FlateEncoder::CloneDict() {
@@ -422,27 +422,27 @@ void CPDF_FlateEncoder::CloneDict() {
}
CPDF_FlateEncoder::CPDF_FlateEncoder(CPDF_Stream* pStream, bool bFlateEncode)
- : m_dwSize(0) {
- m_Acc.LoadAllData(pStream, true);
+ : m_dwSize(0), m_pAcc(pdfium::MakeRetain<CPDF_StreamAcc>(pStream)) {
+ m_pAcc->LoadAllData(true);
bool bHasFilter = pStream && pStream->HasFilter();
if (bHasFilter && !bFlateEncode) {
- CPDF_StreamAcc destAcc;
- destAcc.LoadAllData(pStream);
- m_dwSize = destAcc.GetSize();
- m_pData = destAcc.DetachData();
+ auto pDestAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream);
+ pDestAcc->LoadAllData();
+ m_dwSize = pDestAcc->GetSize();
+ m_pData = pDestAcc->DetachData();
m_pDict = ToDictionary(pStream->GetDict()->Clone());
m_pDict->RemoveFor("Filter");
return;
}
if (bHasFilter || !bFlateEncode) {
- m_pData = const_cast<uint8_t*>(m_Acc.GetData());
- m_dwSize = m_Acc.GetSize();
+ m_pData = const_cast<uint8_t*>(m_pAcc->GetData());
+ m_dwSize = m_pAcc->GetSize();
m_pDict = pStream->GetDict();
return;
}
// TODO(thestig): Move to Init() and check return value.
uint8_t* buffer = nullptr;
- ::FlateEncode(m_Acc.GetData(), m_Acc.GetSize(), &buffer, &m_dwSize);
+ ::FlateEncode(m_pAcc->GetData(), m_pAcc->GetSize(), &buffer, &m_dwSize);
m_pData = std::unique_ptr<uint8_t, FxFreeDeleter>(buffer);
m_pDict = ToDictionary(pStream->GetDict()->Clone());
m_pDict->SetNewFor<CPDF_Number>("Length", static_cast<int>(m_dwSize));