Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp

Issue 1192743004: Cleanup: Do not check pointers before deleting them. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index b7eb05f45225c57f4e92e64dd1a03359dbbf5bcf..3a88c4339e81962c965f4a081adc8f261906f787 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -1967,10 +1967,8 @@ int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause *pPause)
}
void CPDF_Creator::Clear()
{
- if (m_pXRefStream) {
- delete m_pXRefStream;
- m_pXRefStream = NULL;
- }
+ delete m_pXRefStream;
+ m_pXRefStream = NULL;
m_File.Clear();
m_NewObjNumArray.RemoveAll();
if (m_pIDArray) {
@@ -2068,7 +2066,7 @@ void CPDF_Creator::InitID(FX_BOOL bDefault )
CFX_ByteString user_pass = m_pParser->GetPassword();
FX_DWORD flag = PDF_ENCRYPT_CONTENT;
handler.OnCreate(m_pEncryptDict, m_pIDArray, (const uint8_t*)user_pass, user_pass.GetLength(), flag);
- if (m_pCryptoHandler && m_bNewCrypto) {
+ if (m_bNewCrypto) {
delete m_pCryptoHandler;
}
m_pCryptoHandler = new CPDF_StandardCryptoHandler;
@@ -2122,10 +2120,10 @@ void CPDF_Creator::RemoveSecurity()
}
void CPDF_Creator::ResetStandardSecurity()
{
- if ((m_bStandardSecurity || m_bNewCrypto) && m_pCryptoHandler) {
+ if ((m_bStandardSecurity || m_bNewCrypto)) {
Tom Sepez 2015/06/19 21:13:37 nit: double ((
Lei Zhang 2015/06/19 21:30:37 Done.
delete m_pCryptoHandler;
- m_pCryptoHandler = NULL;
}
+ m_pCryptoHandler = NULL;
Tom Sepez 2015/06/19 21:13:37 I don't think you can pull this out of the if. If
Lei Zhang 2015/06/19 21:30:37 Done.
m_bNewCrypto = FALSE;
if (!m_bStandardSecurity) {
return;
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp » ('j') | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698