OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/fpdfapi/fpdf_edit/editint.h" | 7 #include "core/fpdfapi/fpdf_edit/editint.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 } | 463 } |
464 m_bNewData = TRUE; | 464 m_bNewData = TRUE; |
465 // TODO(thestig): Move to Init() and check return value. | 465 // TODO(thestig): Move to Init() and check return value. |
466 if (bXRefStream) | 466 if (bXRefStream) |
467 ::PngEncode(pBuffer, size, &m_pData, &m_dwSize); | 467 ::PngEncode(pBuffer, size, &m_pData, &m_dwSize); |
468 else | 468 else |
469 ::FlateEncode(pBuffer, size, &m_pData, &m_dwSize); | 469 ::FlateEncode(pBuffer, size, &m_pData, &m_dwSize); |
470 } | 470 } |
471 | 471 |
472 CPDF_FlateEncoder::~CPDF_FlateEncoder() { | 472 CPDF_FlateEncoder::~CPDF_FlateEncoder() { |
473 if (m_bCloned && m_pDict) | 473 if (m_bCloned) |
474 m_pDict->Release(); | 474 delete m_pDict; |
475 if (m_bNewData) | 475 if (m_bNewData) |
476 FX_Free(m_pData); | 476 FX_Free(m_pData); |
477 } | 477 } |
478 | 478 |
479 class CPDF_Encryptor { | 479 class CPDF_Encryptor { |
480 public: | 480 public: |
481 CPDF_Encryptor(CPDF_CryptoHandler* pHandler, | 481 CPDF_Encryptor(CPDF_CryptoHandler* pHandler, |
482 int objnum, | 482 int objnum, |
483 uint8_t* src_data, | 483 uint8_t* src_data, |
484 uint32_t src_size); | 484 uint32_t src_size); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 m_Offset(0), | 896 m_Offset(0), |
897 m_iStage(-1), | 897 m_iStage(-1), |
898 m_dwFlags(0), | 898 m_dwFlags(0), |
899 m_Pos(nullptr), | 899 m_Pos(nullptr), |
900 m_XrefStart(0), | 900 m_XrefStart(0), |
901 m_pIDArray(nullptr), | 901 m_pIDArray(nullptr), |
902 m_FileVersion(0) {} | 902 m_FileVersion(0) {} |
903 | 903 |
904 CPDF_Creator::~CPDF_Creator() { | 904 CPDF_Creator::~CPDF_Creator() { |
905 ResetStandardSecurity(); | 905 ResetStandardSecurity(); |
906 if (m_bEncryptCloned && m_pEncryptDict) { | 906 if (m_bEncryptCloned) { |
907 m_pEncryptDict->Release(); | 907 delete m_pEncryptDict; |
908 m_pEncryptDict = nullptr; | 908 m_pEncryptDict = nullptr; |
909 } | 909 } |
910 Clear(); | 910 Clear(); |
911 } | 911 } |
912 | 912 |
913 int32_t CPDF_Creator::WriteIndirectObjectToStream(const CPDF_Object* pObj) { | 913 int32_t CPDF_Creator::WriteIndirectObjectToStream(const CPDF_Object* pObj) { |
914 if (!m_pXRefStream) | 914 if (!m_pXRefStream) |
915 return 1; | 915 return 1; |
916 | 916 |
917 uint32_t objnum = pObj->GetObjNum(); | 917 uint32_t objnum = pObj->GetObjNum(); |
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2013 m_pCryptoHandler = nullptr; | 2013 m_pCryptoHandler = nullptr; |
2014 } | 2014 } |
2015 void CPDF_Creator::ResetStandardSecurity() { | 2015 void CPDF_Creator::ResetStandardSecurity() { |
2016 if (!m_bLocalCryptoHandler) | 2016 if (!m_bLocalCryptoHandler) |
2017 return; | 2017 return; |
2018 | 2018 |
2019 delete m_pCryptoHandler; | 2019 delete m_pCryptoHandler; |
2020 m_pCryptoHandler = nullptr; | 2020 m_pCryptoHandler = nullptr; |
2021 m_bLocalCryptoHandler = FALSE; | 2021 m_bLocalCryptoHandler = FALSE; |
2022 } | 2022 } |
OLD | NEW |