summaryrefslogtreecommitdiff
path: root/core/fpdfapi/edit
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/edit')
-rw-r--r--core/fpdfapi/edit/cpdf_creator.cpp8
-rw-r--r--core/fpdfapi/edit/cpdf_creator.h3
2 files changed, 7 insertions, 4 deletions
diff --git a/core/fpdfapi/edit/cpdf_creator.cpp b/core/fpdfapi/edit/cpdf_creator.cpp
index 5d4fac478d..aa8c751046 100644
--- a/core/fpdfapi/edit/cpdf_creator.cpp
+++ b/core/fpdfapi/edit/cpdf_creator.cpp
@@ -619,10 +619,11 @@ void CPDF_Creator::InitID() {
if (m_pEncryptDict) {
ASSERT(m_pParser);
if (m_pEncryptDict->GetStringFor("Filter") == "Standard") {
- ByteString user_pass = m_pParser->GetPassword();
+ m_pNewEncryptDict = ToDictionary(m_pEncryptDict->Clone());
+ m_pEncryptDict = m_pNewEncryptDict.get();
m_pSecurityHandler = pdfium::MakeUnique<CPDF_SecurityHandler>();
- m_pSecurityHandler->OnCreate(m_pEncryptDict.Get(), m_pIDArray.get(),
- user_pass);
+ m_pSecurityHandler->OnCreate(m_pNewEncryptDict.get(), m_pIDArray.get(),
+ m_pParser->GetPassword());
m_bSecurityChanged = true;
}
}
@@ -666,6 +667,7 @@ void CPDF_Creator::RemoveSecurity() {
m_pSecurityHandler.Reset();
m_bSecurityChanged = true;
m_pEncryptDict = nullptr;
+ m_pNewEncryptDict.reset();
}
CPDF_CryptoHandler* CPDF_Creator::GetCryptoHandler() {
diff --git a/core/fpdfapi/edit/cpdf_creator.h b/core/fpdfapi/edit/cpdf_creator.h
index 39e0950af6..96643c882f 100644
--- a/core/fpdfapi/edit/cpdf_creator.h
+++ b/core/fpdfapi/edit/cpdf_creator.h
@@ -75,7 +75,8 @@ class CPDF_Creator {
UnownedPtr<CPDF_Document> const m_pDocument;
UnownedPtr<const CPDF_Parser> const m_pParser;
- UnownedPtr<CPDF_Dictionary> m_pEncryptDict;
+ UnownedPtr<const CPDF_Dictionary> m_pEncryptDict;
+ std::unique_ptr<CPDF_Dictionary> m_pNewEncryptDict;
fxcrt::MaybeOwned<CPDF_SecurityHandler> m_pSecurityHandler;
UnownedPtr<const CPDF_Object> m_pMetadata;
uint32_t m_dwLastObjNum;