summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-06-08 20:39:04 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-08 20:39:04 +0000
commit8ef4ef26481d8ed80d33b898bcff829fa7c0999c (patch)
tree35eab2b23ededb258181636fe7c76491997180aa /core/fpdfapi
parent84a331e041ff22718945e467bce15c177842e139 (diff)
downloadpdfium-8ef4ef26481d8ed80d33b898bcff829fa7c0999c.tar.xz
Move getting the CPDF_CryptoHandler into CPDF_Creator::WriteStream()
No reason to get it outside and pass it in. Change-Id: I75e3bbd361c04e195004d7c538145dfd56294816 Reviewed-on: https://pdfium-review.googlesource.com/34731 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/edit/cpdf_creator.cpp11
-rw-r--r--core/fpdfapi/edit/cpdf_creator.h4
2 files changed, 6 insertions, 9 deletions
diff --git a/core/fpdfapi/edit/cpdf_creator.cpp b/core/fpdfapi/edit/cpdf_creator.cpp
index 60872c2059..ff8d4bb82f 100644
--- a/core/fpdfapi/edit/cpdf_creator.cpp
+++ b/core/fpdfapi/edit/cpdf_creator.cpp
@@ -151,9 +151,10 @@ CPDF_Creator::CPDF_Creator(CPDF_Document* pDoc,
CPDF_Creator::~CPDF_Creator() {}
-bool CPDF_Creator::WriteStream(const CPDF_Object* pStream,
- uint32_t objnum,
- CPDF_CryptoHandler* pCrypto) {
+bool CPDF_Creator::WriteStream(const CPDF_Object* pStream, uint32_t objnum) {
+ CPDF_CryptoHandler* pCrypto =
+ pStream != m_pMetadata ? GetCryptoHandler() : nullptr;
+
CPDF_FlateEncoder encoder(pStream->AsStream(), pStream != m_pMetadata);
CPDF_Encryptor encryptor(pCrypto, objnum, encoder.GetSpan());
if (static_cast<uint32_t>(encoder.GetDict()->GetIntegerFor("Length")) !=
@@ -183,9 +184,7 @@ bool CPDF_Creator::WriteIndirectObj(uint32_t objnum, const CPDF_Object* pObj) {
return false;
if (pObj->IsStream()) {
- CPDF_CryptoHandler* pHandler =
- pObj != m_pMetadata ? GetCryptoHandler() : nullptr;
- if (!WriteStream(pObj, objnum, pHandler))
+ if (!WriteStream(pObj, objnum))
return false;
} else if (!WriteDirectObj(objnum, pObj, true)) {
return false;
diff --git a/core/fpdfapi/edit/cpdf_creator.h b/core/fpdfapi/edit/cpdf_creator.h
index af1a486d44..9c760edeae 100644
--- a/core/fpdfapi/edit/cpdf_creator.h
+++ b/core/fpdfapi/edit/cpdf_creator.h
@@ -55,9 +55,7 @@ class CPDF_Creator {
bool WriteDirectObj(uint32_t objnum, const CPDF_Object* pObj, bool bEncrypt);
bool WriteIndirectObj(uint32_t objnum, const CPDF_Object* pObj);
- bool WriteStream(const CPDF_Object* pStream,
- uint32_t objnum,
- CPDF_CryptoHandler* pCrypto);
+ bool WriteStream(const CPDF_Object* pStream, uint32_t objnum);
CPDF_CryptoHandler* GetCryptoHandler();