From 796c908e7b7bdde819a1e5a4bfd3576d8e8859d6 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 16 Jul 2015 18:45:22 -0700 Subject: Merge to XFA: Cleanup: Do not check pointers before deleting them, part 2. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1195363002 . (cherry picked from commit 21bf242a31eff79f754c5e9c3b41c52e33483bb0) Review URL: https://codereview.chromium.org/1235753006 . --- fpdfsdk/src/formfiller/FFL_ComboBox.cpp | 6 +----- fpdfsdk/src/formfiller/FFL_ListBox.cpp | 6 +----- fpdfsdk/src/formfiller/FFL_TextField.cpp | 7 +------ fpdfsdk/src/fpdf_transformpage.cpp | 3 +-- fpdfsdk/src/fpdftext.cpp | 11 ++--------- fpdfsdk/src/javascript/JS_Context.cpp | 6 +----- fpdfsdk/src/javascript/JS_Runtime.cpp | 3 +-- fpdfsdk/src/pdfwindow/PWL_FontMap.cpp | 9 +++------ 8 files changed, 11 insertions(+), 40 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp index 4ceb1e9af3..b0c7b2d941 100644 --- a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp +++ b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp @@ -23,11 +23,7 @@ CFFL_ComboBox::CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) : CFFL_ComboBox::~CFFL_ComboBox() { - if (m_pFontMap) - { - delete m_pFontMap; - m_pFontMap = NULL; - } + delete m_pFontMap; } PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam() diff --git a/fpdfsdk/src/formfiller/FFL_ListBox.cpp b/fpdfsdk/src/formfiller/FFL_ListBox.cpp index 28dcf340ad..c105cfcbdd 100644 --- a/fpdfsdk/src/formfiller/FFL_ListBox.cpp +++ b/fpdfsdk/src/formfiller/FFL_ListBox.cpp @@ -26,11 +26,7 @@ CFFL_ListBox::CFFL_ListBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) : CFFL_ListBox::~CFFL_ListBox() { - if (m_pFontMap) - { - delete m_pFontMap; - m_pFontMap = NULL; - } + delete m_pFontMap; } PWL_CREATEPARAM CFFL_ListBox::GetCreateParam() diff --git a/fpdfsdk/src/formfiller/FFL_TextField.cpp b/fpdfsdk/src/formfiller/FFL_TextField.cpp index 83c7f35ba9..db69101ec2 100644 --- a/fpdfsdk/src/formfiller/FFL_TextField.cpp +++ b/fpdfsdk/src/formfiller/FFL_TextField.cpp @@ -19,12 +19,7 @@ CFFL_TextField::CFFL_TextField(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) CFFL_TextField::~CFFL_TextField() { - if (m_pFontMap) - { - delete m_pFontMap; - m_pFontMap = NULL; - } - + delete m_pFontMap; } PWL_CREATEPARAM CFFL_TextField::GetCreateParam() diff --git a/fpdfsdk/src/fpdf_transformpage.cpp b/fpdfsdk/src/fpdf_transformpage.cpp index 7bec77c2df..ad6e042179 100644 --- a/fpdfsdk/src/fpdf_transformpage.cpp +++ b/fpdfsdk/src/fpdf_transformpage.cpp @@ -222,8 +222,7 @@ DLLEXPORT FPDF_CLIPPATH STDCALL FPDF_CreateClipPath(float left, float bottom, fl DLLEXPORT void STDCALL FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath) { - if(clipPath) - delete (CPDF_ClipPath*)clipPath; + delete (CPDF_ClipPath*)clipPath; } void OutputPath(CFX_ByteTextBuf& buf, CPDF_Path path) diff --git a/fpdfsdk/src/fpdftext.cpp b/fpdfsdk/src/fpdftext.cpp index acfc79238a..7b07a13890 100644 --- a/fpdfsdk/src/fpdftext.cpp +++ b/fpdfsdk/src/fpdftext.cpp @@ -32,11 +32,7 @@ DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page) } DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page) { - if (text_page){ - IPDF_TextPage* textpage=(IPDF_TextPage*)text_page; - delete textpage; - text_page=NULL; - } + delete (IPDF_TextPage*)text_page; } DLLEXPORT int STDCALL FPDFText_CountChars(FPDF_TEXTPAGE text_page) { @@ -252,9 +248,6 @@ DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page,int link_index, } DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page) { - if (!link_page) return; - IPDF_LinkExtract* pageLink=(IPDF_LinkExtract*)link_page; - delete pageLink; - pageLink =NULL; + delete (IPDF_LinkExtract*)link_page; } diff --git a/fpdfsdk/src/javascript/JS_Context.cpp b/fpdfsdk/src/javascript/JS_Context.cpp index f41cf9ec13..e789657469 100644 --- a/fpdfsdk/src/javascript/JS_Context.cpp +++ b/fpdfsdk/src/javascript/JS_Context.cpp @@ -24,11 +24,7 @@ CJS_Context::CJS_Context(CJS_Runtime* pRuntime) : CJS_Context::~CJS_Context(void) { - if (m_pEventHandler) - { - delete m_pEventHandler; - m_pEventHandler = NULL; - } + delete m_pEventHandler; } CPDFSDK_Document* CJS_Context::GetReaderDocument() diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp index 2ffc9ff988..bfea274eed 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime.cpp @@ -63,8 +63,7 @@ void CJS_RuntimeFactory::Release() void CJS_RuntimeFactory::DeleteJSRuntime(IFXJS_Runtime* pRuntime) { - if(pRuntime) - delete (CJS_Runtime*)pRuntime; + delete (CJS_Runtime*)pRuntime; } CJS_GlobalData* CJS_RuntimeFactory::NewGlobalData(CPDFDoc_Environment* pApp) diff --git a/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp b/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp index 943e4979b2..1f20d12aca 100644 --- a/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp @@ -21,13 +21,10 @@ CPWL_FontMap::CPWL_FontMap(IFX_SystemHandler* pSystemHandler) : CPWL_FontMap::~CPWL_FontMap() { - if (m_pPDFDoc) - { - delete m_pPDFDoc; - m_pPDFDoc = NULL; - } + delete m_pPDFDoc; + m_pPDFDoc = NULL; - Empty(); + Empty(); } void CPWL_FontMap::SetSystemHandler(IFX_SystemHandler* pSystemHandler) -- cgit v1.2.3