diff options
author | Lei Zhang <thestig@chromium.org> | 2015-06-19 17:26:17 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-06-19 17:26:17 -0700 |
commit | 6d8b1c2c7b1cbada20109f70ae971a4192330bb5 (patch) | |
tree | e755b7cb2624622cba606134493d25fb7f1ce6c8 /fpdfsdk | |
parent | 9883a7da2d4f31910073c03e703d5b97a45d9254 (diff) | |
download | pdfium-6d8b1c2c7b1cbada20109f70ae971a4192330bb5.tar.xz |
Merge to XFA: Cleanup: Do not check pointers before deleting them.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1192743004.
(cherry picked from commit cfac954abcab7caf47d3fa3d641c553cba998271)
Review URL: https://codereview.chromium.org/1196783003.
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/src/formfiller/FFL_IFormFiller.cpp | 13 | ||||
-rw-r--r-- | fpdfsdk/src/fpdf_dataavail.cpp | 5 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfview.cpp | 17 | ||||
-rw-r--r-- | fpdfsdk/src/fsdk_mgr.cpp | 9 | ||||
-rw-r--r-- | fpdfsdk/src/fsdk_rendercontext.cpp | 16 | ||||
-rw-r--r-- | fpdfsdk/src/fxedit/fxet_edit.cpp | 24 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/app.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/src/pdfwindow/PWL_ListBox.cpp | 19 | ||||
-rw-r--r-- | fpdfsdk/src/pdfwindow/PWL_Wnd.cpp | 2 |
9 files changed, 40 insertions, 67 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp index 4a5a7bcd96..d4ca0235b3 100644 --- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp +++ b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp @@ -707,14 +707,11 @@ void CFFL_IFormFiller::RemoveFormFiller(CPDFSDK_Annot* pAnnot) void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot) { - CFFL_FormFiller * pFormFiller = NULL; - - if (m_Maps.Lookup(pAnnot,pFormFiller)) - { - if (pFormFiller) - delete pFormFiller; - m_Maps.RemoveKey(pAnnot); - } + CFFL_FormFiller* pFormFiller = nullptr; + if (m_Maps.Lookup(pAnnot,pFormFiller)) { + delete pFormFiller; + m_Maps.RemoveKey(pAnnot); + } } void CFFL_IFormFiller::SetFocusAnnotTab(CPDFSDK_Annot* pWidget, FX_BOOL bSameField, FX_BOOL bNext) diff --git a/fpdfsdk/src/fpdf_dataavail.cpp b/fpdfsdk/src/fpdf_dataavail.cpp index 7189dc0788..2121f2678a 100644 --- a/fpdfsdk/src/fpdf_dataavail.cpp +++ b/fpdfsdk/src/fpdf_dataavail.cpp @@ -90,7 +90,7 @@ public: ~CFPDF_DataAvail() { - if (m_pDataAvail) delete m_pDataAvail; + delete m_pDataAvail; } IPDF_DataAvail* m_pDataAvail; @@ -109,8 +109,7 @@ DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, FPDF_FIL DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail) { - if (avail == NULL) return; - delete (CFPDF_DataAvail*)avail; + delete (CFPDF_DataAvail*)avail; } DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints) diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp index 4e6ffb0000..80a9fa52a3 100644 --- a/fpdfsdk/src/fpdfview.cpp +++ b/fpdfsdk/src/fpdfview.cpp @@ -607,14 +607,12 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int #endif #endif - if (bBackgroundAlphaNeeded) - { - if (pBitmap) - delete pBitmap; - pBitmap = NULL; - } - delete pContext; - pPage->RemovePrivateData((void*)1); + if (bBackgroundAlphaNeeded) { + delete pBitmap; + pBitmap = NULL; + } + delete pContext; + pPage->RemovePrivateData((void*)1); } #endif @@ -769,8 +767,7 @@ DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap) DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap) { - if (bitmap == NULL) return; - delete (CFX_DIBitmap*)bitmap; + delete (CFX_DIBitmap*)bitmap; } void FPDF_RenderPage_Retail(CRenderContext* pContext, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp index 69a9929bc3..0f71e6eaa0 100644 --- a/fpdfsdk/src/fsdk_mgr.cpp +++ b/fpdfsdk/src/fsdk_mgr.cpp @@ -230,7 +230,6 @@ CPDFDoc_Environment::CPDFDoc_Environment(CPDFXFA_Document* pDoc) : CPDFDoc_Environment::~CPDFDoc_Environment() { - delete m_pIFormFiller; m_pIFormFiller = NULL; @@ -634,11 +633,9 @@ CPDFSDK_PageView::~CPDFSDK_PageView() pAnnotHandlerMgr->ReleaseAnnot(pAnnot); } m_fxAnnotArray.RemoveAll(); - if(m_pAnnotList) - { - delete m_pAnnotList; - m_pAnnotList = NULL; - } + + delete m_pAnnotList; + m_pAnnotList = NULL; } void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions, FX_RECT* pClip) diff --git a/fpdfsdk/src/fsdk_rendercontext.cpp b/fpdfsdk/src/fsdk_rendercontext.cpp index 70c4a17248..4b7242d2b9 100644 --- a/fpdfsdk/src/fsdk_rendercontext.cpp +++ b/fpdfsdk/src/fsdk_rendercontext.cpp @@ -21,15 +21,15 @@ void CRenderContext::Clear() CRenderContext::~CRenderContext() { - if (m_pRenderer) delete m_pRenderer; - if (m_pContext) delete m_pContext; - if (m_pDevice) delete m_pDevice; - if (m_pAnnots) delete m_pAnnots; - if (m_pOptions->m_pOCContext) delete m_pOptions->m_pOCContext; - if (m_pOptions) delete m_pOptions; + delete m_pRenderer; + delete m_pContext; + delete m_pDevice; + delete m_pAnnots; + delete m_pOptions->m_pOCContext; + delete m_pOptions; #ifdef _WIN32_WCE - if (m_pBitmap) delete m_pBitmap; - if (m_hBitmap) DeleteObject(m_hBitmap); + delete m_pBitmap; + if (m_hBitmap) DeleteObject(m_hBitmap); #endif } diff --git a/fpdfsdk/src/fxedit/fxet_edit.cpp b/fpdfsdk/src/fxedit/fxet_edit.cpp index 70d7b77553..8e109b5cf8 100644 --- a/fpdfsdk/src/fxedit/fxet_edit.cpp +++ b/fpdfsdk/src/fxedit/fxet_edit.cpp @@ -971,19 +971,11 @@ CFX_Edit::CFX_Edit(IPDF_VariableText * pVT) : CFX_Edit::~CFX_Edit() { - if (m_pVTProvide) - { - delete m_pVTProvide; - m_pVTProvide = NULL; - } - - if (m_pIterator) - { - delete m_pIterator; - m_pIterator = NULL; - } - - ASSERT(m_pGroupUndoItem == NULL); + delete m_pVTProvide; + m_pVTProvide = NULL; + delete m_pIterator; + m_pIterator = NULL; + ASSERT(m_pGroupUndoItem == NULL); } // public methods @@ -997,10 +989,8 @@ void CFX_Edit::Initialize() void CFX_Edit::SetFontMap(IFX_Edit_FontMap * pFontMap) { - if (m_pVTProvide) - delete m_pVTProvide; - - m_pVT->SetProvider(m_pVTProvide = new CFX_Edit_Provider(pFontMap)); + delete m_pVTProvide; + m_pVT->SetProvider(m_pVTProvide = new CFX_Edit_Provider(pFontMap)); } void CFX_Edit::SetVTProvider(IPDF_VariableText_Provider* pProvider) diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp index adcb7c6281..1438661c23 100644 --- a/fpdfsdk/src/javascript/app.cpp +++ b/fpdfsdk/src/javascript/app.cpp @@ -373,7 +373,7 @@ FX_BOOL app::alert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& v swMsg += L", "; } - if(pValue) delete pValue; + delete pValue; } } diff --git a/fpdfsdk/src/pdfwindow/PWL_ListBox.cpp b/fpdfsdk/src/pdfwindow/PWL_ListBox.cpp index 0328ee55d6..48fb409b7b 100644 --- a/fpdfsdk/src/pdfwindow/PWL_ListBox.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_ListBox.cpp @@ -90,13 +90,9 @@ CPWL_ListBox::CPWL_ListBox() : CPWL_ListBox::~CPWL_ListBox() { - IFX_List::DelList(m_pList); - - if (m_pListNotify) - { - delete m_pListNotify; - m_pListNotify = NULL; - } + IFX_List::DelList(m_pList); + delete m_pListNotify; + m_pListNotify = NULL; } CFX_ByteString CPWL_ListBox::GetClassName() const @@ -108,7 +104,7 @@ void CPWL_ListBox::OnCreated() { if (m_pList) { - if (m_pListNotify) delete m_pListNotify; + delete m_pListNotify; m_pList->SetFontMap(GetFontMap()); m_pList->SetNotify(m_pListNotify = new CPWL_List_Notify(this)); @@ -123,11 +119,8 @@ void CPWL_ListBox::OnCreated() void CPWL_ListBox::OnDestroy() { - if (m_pListNotify) - { - delete m_pListNotify; - m_pListNotify = NULL; - } + delete m_pListNotify; + m_pListNotify = NULL; } void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream) diff --git a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp index 8ee9967763..dcc6e409a4 100644 --- a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp @@ -71,7 +71,7 @@ CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL) CPWL_TimerHandler::~CPWL_TimerHandler() { - if (m_pTimer) delete m_pTimer; + delete m_pTimer; } void CPWL_TimerHandler::BeginTimer(int32_t nElapse) |