From dd427007f2c44b10752e7ee3101c9785f1e46c15 Mon Sep 17 00:00:00 2001 From: weili Date: Tue, 17 May 2016 09:33:34 -0700 Subject: Revert of Remove an unnecessary variable from CPDF_Creator (patchset #1 id:20001 of https://codereview.chromium.org/1988603002/ ) Reason for revert: The variable is still needed, will fix the other way. Original issue's description: > Remove an unnecessary variable from CPDF_Creator > > The variable may not be initialized before using, which caused > errors on DrMemory bot. Since it is not necessary, remove it. > > TBR=thestig@chromium.org > > Committed: https://pdfium.googlesource.com/pdfium/+/47b998b53edbb071bb55c909169be1070126fb22 TBR=dsinclair@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/1987783002 --- core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp | 10 +++++++--- core/fpdfapi/fpdf_edit/include/cpdf_creator.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'core/fpdfapi') diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp index 7604c62240..372506d6cc 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp @@ -881,10 +881,8 @@ CPDF_Creator::CPDF_Creator(CPDF_Document* pDoc) m_bSecurityChanged(FALSE), m_pEncryptDict(m_pParser ? m_pParser->GetEncryptDict() : nullptr), m_dwEncryptObjNum(0), - m_bEncryptCloned(FALSE), m_pCryptoHandler(m_pParser ? m_pParser->GetCryptoHandler() : nullptr), m_pMetadata(nullptr), - m_pXRefStream(nullptr), m_ObjectStreamSize(200), m_dwLastObjNum(m_pDocument->GetLastObjNum()), m_Offset(0), @@ -1961,9 +1959,11 @@ void CPDF_Creator::InitID(FX_BOOL bDefault) { CPDF_SecurityHandler handler; handler.OnCreate(m_pEncryptDict, m_pIDArray, user_pass.raw_str(), user_pass.GetLength(), flag); - delete m_pCryptoHandler; + if (m_bLocalCryptoHandler) + delete m_pCryptoHandler; m_pCryptoHandler = new CPDF_CryptoHandler; m_pCryptoHandler->Init(m_pEncryptDict, &handler); + m_bLocalCryptoHandler = TRUE; m_bSecurityChanged = TRUE; } } @@ -2008,6 +2008,10 @@ void CPDF_Creator::RemoveSecurity() { m_pCryptoHandler = nullptr; } void CPDF_Creator::ResetStandardSecurity() { + if (!m_bLocalCryptoHandler) + return; + delete m_pCryptoHandler; m_pCryptoHandler = nullptr; + m_bLocalCryptoHandler = FALSE; } diff --git a/core/fpdfapi/fpdf_edit/include/cpdf_creator.h b/core/fpdfapi/fpdf_edit/include/cpdf_creator.h index c63c864668..c932dc0804 100644 --- a/core/fpdfapi/fpdf_edit/include/cpdf_creator.h +++ b/core/fpdfapi/fpdf_edit/include/cpdf_creator.h @@ -80,6 +80,7 @@ class CPDF_Creator { uint32_t m_dwEncryptObjNum; FX_BOOL m_bEncryptCloned; CPDF_CryptoHandler* m_pCryptoHandler; + FX_BOOL m_bLocalCryptoHandler; CPDF_Object* m_pMetadata; std::unique_ptr m_pXRefStream; int32_t m_ObjectStreamSize; -- cgit v1.2.3