summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-07-16 18:28:49 -0700
committerLei Zhang <thestig@chromium.org>2015-07-16 18:28:49 -0700
commit21bf242a31eff79f754c5e9c3b41c52e33483bb0 (patch)
tree0eff85fa75ab9091254f7560b37b95408ba8975e
parent6915e7bd9e0892f143936697c6ba233510fb13dc (diff)
downloadpdfium-21bf242a31eff79f754c5e9c3b41c52e33483bb0.tar.xz
Cleanup: Do not check pointers before deleting them, part 2.
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1195363002 .
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render.cpp20
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp28
-rw-r--r--core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp12
-rw-r--r--core/src/fxge/agg/src/fx_agg_driver.cpp4
-rw-r--r--core/src/fxge/android/fpf_skiamodule.cpp6
-rw-r--r--core/src/fxge/apple/fx_mac_imp.cpp4
-rw-r--r--core/src/fxge/win32/fx_win32_device.cpp4
-rw-r--r--core/src/fxge/win32/fx_win32_dwrite.cpp4
-rw-r--r--fpdfsdk/src/formfiller/FFL_ComboBox.cpp6
-rw-r--r--fpdfsdk/src/formfiller/FFL_ListBox.cpp6
-rw-r--r--fpdfsdk/src/formfiller/FFL_TextField.cpp7
-rw-r--r--fpdfsdk/src/fpdf_transformpage.cpp3
-rw-r--r--fpdfsdk/src/fpdftext.cpp11
-rw-r--r--fpdfsdk/src/javascript/JS_Context.cpp6
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp3
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_FontMap.cpp9
16 files changed, 32 insertions, 101 deletions
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
index c4a9d7761b..a894e846ee 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -202,9 +202,7 @@ CPDF_RenderStatus::CPDF_RenderStatus()
CPDF_RenderStatus::~CPDF_RenderStatus()
{
- if (m_pObjectRenderer) {
- delete m_pObjectRenderer;
- }
+ delete m_pObjectRenderer;
}
FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext, CFX_RenderDevice* pDevice,
@@ -665,9 +663,7 @@ void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath, const CFX_Affine
ProcessText(pText, pObj2Device, pTextClippingPath);
}
}
- if (pTextClippingPath) {
- delete pTextClippingPath;
- }
+ delete pTextClippingPath;
}
void CPDF_RenderStatus::DrawClipPath(CPDF_ClipPath ClipPath, const CFX_AffineMatrix* pObj2Device)
{
@@ -859,9 +855,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj,
Transparency |= PDFTRANS_GROUP;
}
CompositeDIBitmap(bitmap, rect.left, rect.top, 0, 255, blend_type, Transparency);
- if (oriDevice) {
- delete oriDevice;
- }
+ delete oriDevice;
return TRUE;
}
CFX_DIBitmap* CPDF_RenderStatus::GetBackdrop(const CPDF_PageObject* pObj, const FX_RECT& rect, int& left, int& top,
@@ -1271,9 +1265,7 @@ CPDF_DeviceBuffer::CPDF_DeviceBuffer()
}
CPDF_DeviceBuffer::~CPDF_DeviceBuffer()
{
- if (m_pBitmap) {
- delete m_pBitmap;
- }
+ delete m_pBitmap;
}
FX_BOOL CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, CFX_RenderDevice* pDevice, FX_RECT* pRect,
const CPDF_PageObject* pObj, int max_dpi)
@@ -1330,9 +1322,7 @@ CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer()
}
CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer()
{
- if (m_pBitmapDevice) {
- delete m_pBitmapDevice;
- }
+ delete m_pBitmapDevice;
}
#define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024)
FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, CFX_RenderDevice* pDevice, FX_RECT* pRect,
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
index f3f0375f53..0730206e23 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -297,21 +297,13 @@ CPDF_ImageRenderer::CPDF_ImageRenderer()
}
CPDF_ImageRenderer::~CPDF_ImageRenderer()
{
- if (m_pQuickStretcher) {
- delete m_pQuickStretcher;
- }
- if (m_pTransformer) {
- delete m_pTransformer;
- }
+ delete m_pQuickStretcher;
+ delete m_pTransformer;
if (m_DeviceHandle) {
m_pRenderStatus->m_pDevice->CancelDIBits(m_DeviceHandle);
}
- if (m_LoadHandle) {
- delete (CPDF_ProgressiveImageLoaderHandle*)m_LoadHandle;
- }
- if (m_pClone) {
- delete m_pClone;
- }
+ delete (CPDF_ProgressiveImageLoaderHandle*)m_LoadHandle;
+ delete m_pClone;
}
FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource()
{
@@ -813,15 +805,11 @@ CPDF_QuickStretcher::CPDF_QuickStretcher()
}
CPDF_QuickStretcher::~CPDF_QuickStretcher()
{
- if (m_pBitmap) {
- delete m_pBitmap;
- }
+ delete m_pBitmap;
if (m_pCS) {
m_pCS->ReleaseCS();
}
- if (m_pDecoder) {
- delete m_pDecoder;
- }
+ delete m_pDecoder;
}
ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(const uint8_t* src_buf, FX_DWORD src_size, int width, int height,
int nComps, int bpc, const CPDF_Dictionary* pParams);
@@ -1085,9 +1073,7 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
} else {
FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height);
}
- if (pFunc) {
- delete pFunc;
- }
+ delete pFunc;
FX_Free(pTransfer);
return pMask;
}
diff --git a/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp b/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp
index 929180e0b5..622f04b160 100644
--- a/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp
@@ -3027,9 +3027,7 @@ CJBig2_SymbolDict *CJBig2_SDDProc::decode_Huffman(CJBig2_BitStream *pStream,
return pDict;
failed:
for(I = 0; I < NSYMSDECODED; I++) {
- if (SDNEWSYMS[I]) {
- delete SDNEWSYMS[I];
- }
+ delete SDNEWSYMS[I];
}
m_pModule->JBig2_Free(SDNEWSYMS);
if(SDREFAGG == 0) {
@@ -3094,15 +3092,11 @@ CJBig2_Image *CJBig2_HTRDProc::decode_Arith(CJBig2_ArithDecoder *pArithDecoder,
}
}
m_pModule->JBig2_Free(GI);
- if(HSKIP) {
- delete HSKIP;
- }
+ delete HSKIP;
delete pGID;
return HTREG;
failed:
- if(HSKIP) {
- delete HSKIP;
- }
+ delete HSKIP;
delete pGID;
delete HTREG;
return NULL;
diff --git a/core/src/fxge/agg/src/fx_agg_driver.cpp b/core/src/fxge/agg/src/fx_agg_driver.cpp
index 8e7846abd4..475e5f6442 100644
--- a/core/src/fxge/agg/src/fx_agg_driver.cpp
+++ b/core/src/fxge/agg/src/fx_agg_driver.cpp
@@ -207,9 +207,7 @@ CFX_AggDeviceDriver::~CFX_AggDeviceDriver()
{
delete m_pClipRgn;
for (int i = 0; i < m_StateStack.GetSize(); i ++)
- if (m_StateStack[i]) {
- delete (CFX_ClipRgn*)m_StateStack[i];
- }
+ delete (CFX_ClipRgn*)m_StateStack[i];
DestroyPlatform();
}
#if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
diff --git a/core/src/fxge/android/fpf_skiamodule.cpp b/core/src/fxge/android/fpf_skiamodule.cpp
index 37bfd9cabb..296073c4e2 100644
--- a/core/src/fxge/android/fpf_skiamodule.cpp
+++ b/core/src/fxge/android/fpf_skiamodule.cpp
@@ -22,10 +22,8 @@ CFPF_SkiaDeviceModule::~CFPF_SkiaDeviceModule()
}
void CFPF_SkiaDeviceModule::Destroy()
{
- if (gs_pPFModule) {
- delete (CFPF_SkiaDeviceModule*)gs_pPFModule;
- gs_pPFModule = NULL;
- }
+ delete (CFPF_SkiaDeviceModule*)gs_pPFModule;
+ gs_pPFModule = NULL;
}
IFPF_FontMgr* CFPF_SkiaDeviceModule::GetFontMgr()
{
diff --git a/core/src/fxge/apple/fx_mac_imp.cpp b/core/src/fxge/apple/fx_mac_imp.cpp
index 3a9b9f9ec3..04b04b8ba8 100644
--- a/core/src/fxge/apple/fx_mac_imp.cpp
+++ b/core/src/fxge/apple/fx_mac_imp.cpp
@@ -100,9 +100,7 @@ void CFX_GEModule::InitPlatform()
}
void CFX_GEModule::DestroyPlatform()
{
- if (m_pPlatformData) {
- delete (CApplePlatform *) m_pPlatformData;
- }
+ delete (CApplePlatform *)m_pPlatformData;
m_pPlatformData = NULL;
}
#endif
diff --git a/core/src/fxge/win32/fx_win32_device.cpp b/core/src/fxge/win32/fx_win32_device.cpp
index 899adf5b7c..b0dbc14ebc 100644
--- a/core/src/fxge/win32/fx_win32_device.cpp
+++ b/core/src/fxge/win32/fx_win32_device.cpp
@@ -410,9 +410,7 @@ void CFX_GEModule::InitPlatform()
}
void CFX_GEModule::DestroyPlatform()
{
- if (m_pPlatformData) {
- delete (CWin32Platform*)m_pPlatformData;
- }
+ delete (CWin32Platform*)m_pPlatformData;
m_pPlatformData = NULL;
}
CGdiDeviceDriver::CGdiDeviceDriver(HDC hDC, int device_class)
diff --git a/core/src/fxge/win32/fx_win32_dwrite.cpp b/core/src/fxge/win32/fx_win32_dwrite.cpp
index 3cde3bfd8b..889a5684b7 100644
--- a/core/src/fxge/win32/fx_win32_dwrite.cpp
+++ b/core/src/fxge/win32/fx_win32_dwrite.cpp
@@ -262,9 +262,7 @@ FX_BOOL CDWriteExt::DwRendingString(void* renderTarget, CFX_ClipRgn* pClipRgn, F
}
void CDWriteExt::DwDeleteRenderingTarget(void* renderTarget)
{
- if (renderTarget) {
- delete (CDwGdiTextRenderer*)renderTarget;
- }
+ delete (CDwGdiTextRenderer*)renderTarget;
}
void CDWriteExt::DwDeleteFont(void* pFont)
{
diff --git a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
index 5618e8a62b..d3a494405f 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 ed155fbf3b..a5be60ed4e 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 dca0c23a56..5ede62692b 100644
--- a/fpdfsdk/src/fpdf_transformpage.cpp
+++ b/fpdfsdk/src/fpdf_transformpage.cpp
@@ -211,8 +211,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 aba24f4991..4a6571531c 100644
--- a/fpdfsdk/src/fpdftext.cpp
+++ b/fpdfsdk/src/fpdftext.cpp
@@ -26,11 +26,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)
{
@@ -246,9 +242,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 924ab1ee19..72be34d751 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 f21819ac17..2343eb3a43 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -65,8 +65,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 8dff4eabac..84b8c94363 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)