summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-06-19 14:51:10 -0700
committerLei Zhang <thestig@chromium.org>2015-06-19 14:51:10 -0700
commitcfac954abcab7caf47d3fa3d641c553cba998271 (patch)
tree4cd546a2377e973fec54b75c1002c8c0ff321e8f /fpdfsdk
parentdf558514bf5cb5750d5a7000a843f45f4170d5a4 (diff)
downloadpdfium-cfac954abcab7caf47d3fa3d641c553cba998271.tar.xz
Cleanup: Do not check pointers before deleting them.
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1192743004.
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/src/formfiller/FFL_IFormFiller.cpp13
-rw-r--r--fpdfsdk/src/fpdf_dataavail.cpp5
-rw-r--r--fpdfsdk/src/fpdfview.cpp17
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp46
-rw-r--r--fpdfsdk/src/fsdk_rendercontext.cpp16
-rw-r--r--fpdfsdk/src/fxedit/fxet_edit.cpp24
-rw-r--r--fpdfsdk/src/javascript/app.cpp2
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_ListBox.cpp19
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Wnd.cpp2
9 files changed, 52 insertions, 92 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
index 9969c18b63..464ff3ce6b 100644
--- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
@@ -704,14 +704,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 b6363a8827..b26d2af10a 100644
--- a/fpdfsdk/src/fpdf_dataavail.cpp
+++ b/fpdfsdk/src/fpdf_dataavail.cpp
@@ -87,7 +87,7 @@ public:
~CFPDF_DataAvail()
{
- if (m_pDataAvail) delete m_pDataAvail;
+ delete m_pDataAvail;
}
IPDF_DataAvail* m_pDataAvail;
@@ -106,8 +106,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 54731193dd..9db0554ab3 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -481,14 +481,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
@@ -662,8 +660,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 b8028aad73..5d4680d978 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -239,34 +239,19 @@ CPDFDoc_Environment::CPDFDoc_Environment(CPDF_Document* pDoc) :
CPDFDoc_Environment::~CPDFDoc_Environment()
{
+ delete m_pIFormFiller;
+ m_pIFormFiller = NULL;
+ if (m_pJSRuntime && m_pJSRuntimeFactory)
+ m_pJSRuntimeFactory->DeleteJSRuntime(m_pJSRuntime);
+ m_pJSRuntimeFactory->Release();
- if ( m_pIFormFiller )
- {
- delete m_pIFormFiller;
- m_pIFormFiller = NULL;
- }
- if(m_pJSRuntime && m_pJSRuntimeFactory)
- m_pJSRuntimeFactory->DeleteJSRuntime(m_pJSRuntime);
- m_pJSRuntimeFactory->Release();
-
- if(m_pSysHandler)
- {
- delete m_pSysHandler;
- m_pSysHandler = NULL;
- }
-
- if(m_pAnnotHandlerMgr)
- {
- delete m_pAnnotHandlerMgr;
- m_pAnnotHandlerMgr = NULL;
- }
- if(m_pActionHandler)
- {
- delete m_pActionHandler;
- m_pActionHandler = NULL;
- }
-
+ delete m_pSysHandler;
+ m_pSysHandler = NULL;
+ delete m_pAnnotHandlerMgr;
+ m_pAnnotHandlerMgr = NULL;
+ delete m_pActionHandler;
+ m_pActionHandler = NULL;
}
@@ -639,11 +624,10 @@ 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;
+
m_page->RemovePrivateData((void*)m_page);
if(m_bTakeOverPage) {
delete m_page;
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 896622822c..9d992d0189 100644
--- a/fpdfsdk/src/javascript/app.cpp
+++ b/fpdfsdk/src/javascript/app.cpp
@@ -360,7 +360,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)