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 /core/src/fxge | |
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 'core/src/fxge')
-rw-r--r-- | core/src/fxge/agg/src/fx_agg_driver.cpp | 18 | ||||
-rw-r--r-- | core/src/fxge/android/fpf_skiafontmgr.cpp | 4 | ||||
-rw-r--r-- | core/src/fxge/android/fpf_skiamodule.cpp | 4 | ||||
-rw-r--r-- | core/src/fxge/apple/apple_int.h | 4 | ||||
-rw-r--r-- | core/src/fxge/apple/fx_quartz_device.cpp | 2 | ||||
-rw-r--r-- | core/src/fxge/dib/fx_dib_engine.cpp | 4 | ||||
-rw-r--r-- | core/src/fxge/dib/fx_dib_main.cpp | 26 | ||||
-rw-r--r-- | core/src/fxge/ge/fx_ge.cpp | 12 | ||||
-rw-r--r-- | core/src/fxge/ge/fx_ge_device.cpp | 8 | ||||
-rw-r--r-- | core/src/fxge/ge/fx_ge_font.cpp | 6 | ||||
-rw-r--r-- | core/src/fxge/ge/fx_ge_fontmap.cpp | 4 | ||||
-rw-r--r-- | core/src/fxge/ge/fx_ge_text.cpp | 4 | ||||
-rw-r--r-- | core/src/fxge/skia/fx_skia_device.cpp | 2 | ||||
-rw-r--r-- | core/src/fxge/win32/fx_win32_dib.cpp | 12 | ||||
-rw-r--r-- | core/src/fxge/win32/fx_win32_print.cpp | 4 |
15 files changed, 32 insertions, 82 deletions
diff --git a/core/src/fxge/agg/src/fx_agg_driver.cpp b/core/src/fxge/agg/src/fx_agg_driver.cpp index 49556bd10b..cb01893d5b 100644 --- a/core/src/fxge/agg/src/fx_agg_driver.cpp +++ b/core/src/fxge/agg/src/fx_agg_driver.cpp @@ -205,9 +205,7 @@ CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, int dither_bits, } CFX_AggDeviceDriver::~CFX_AggDeviceDriver() { - if (m_pClipRgn) { - delete m_pClipRgn; - } + delete m_pClipRgn; for (int i = 0; i < m_StateStack.GetSize(); i ++) if (m_StateStack[i]) { delete (CFX_ClipRgn*)m_StateStack[i]; @@ -277,17 +275,13 @@ void CFX_AggDeviceDriver::SaveState() void CFX_AggDeviceDriver::RestoreState(FX_BOOL bKeepSaved) { if (m_StateStack.GetSize() == 0) { - if (m_pClipRgn) { - delete m_pClipRgn; - m_pClipRgn = NULL; - } - return; - } - CFX_ClipRgn* pSavedClip = (CFX_ClipRgn*)m_StateStack[m_StateStack.GetSize() - 1]; - if (m_pClipRgn) { delete m_pClipRgn; m_pClipRgn = NULL; + return; } + CFX_ClipRgn* pSavedClip = (CFX_ClipRgn*)m_StateStack[m_StateStack.GetSize() - 1]; + delete m_pClipRgn; + m_pClipRgn = NULL; if (bKeepSaved) { if (pSavedClip) { m_pClipRgn = FX_NEW CFX_ClipRgn(*pSavedClip); @@ -1625,7 +1619,7 @@ FX_BOOL CFX_FxgeDevice::Create(int width, int height, FXDIB_Format format, int d } CFX_FxgeDevice::~CFX_FxgeDevice() { - if (m_bOwnedBitmap && GetBitmap()) { + if (m_bOwnedBitmap) { delete GetBitmap(); } } diff --git a/core/src/fxge/android/fpf_skiafontmgr.cpp b/core/src/fxge/android/fpf_skiafontmgr.cpp index 2eb0529711..623e2d6f12 100644 --- a/core/src/fxge/android/fpf_skiafontmgr.cpp +++ b/core/src/fxge/android/fpf_skiafontmgr.cpp @@ -245,9 +245,7 @@ CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr() m_FamilyFonts.RemoveAll(); for (int32_t i = m_FontFaces.GetUpperBound(); i >= 0; i--) { CFPF_SkiaFontDescriptor *pFont = (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(i); - if (pFont) { - delete pFont; - } + delete pFont; } m_FontFaces.RemoveAll(); if (m_FTLibrary) { diff --git a/core/src/fxge/android/fpf_skiamodule.cpp b/core/src/fxge/android/fpf_skiamodule.cpp index f1384b466c..1d365472e3 100644 --- a/core/src/fxge/android/fpf_skiamodule.cpp +++ b/core/src/fxge/android/fpf_skiamodule.cpp @@ -18,9 +18,7 @@ IFPF_DeviceModule* FPF_GetDeviceModule() } CFPF_SkiaDeviceModule::~CFPF_SkiaDeviceModule() { - if (m_pFontMgr) { - delete m_pFontMgr; - } + delete m_pFontMgr; } void CFPF_SkiaDeviceModule::Destroy() { diff --git a/core/src/fxge/apple/apple_int.h b/core/src/fxge/apple/apple_int.h index 48476c39a7..715e48d6c2 100644 --- a/core/src/fxge/apple/apple_int.h +++ b/core/src/fxge/apple/apple_int.h @@ -71,9 +71,7 @@ public: } ~CApplePlatform() { - if (m_pFontMapper) { - delete m_pFontMapper; - } + delete m_pFontMapper; } CQuartz2D _quartz2d; IFX_FontMapper* m_pFontMapper; diff --git a/core/src/fxge/apple/fx_quartz_device.cpp b/core/src/fxge/apple/fx_quartz_device.cpp index 0b8353f4b0..c1004d69db 100644 --- a/core/src/fxge/apple/fx_quartz_device.cpp +++ b/core/src/fxge/apple/fx_quartz_device.cpp @@ -1082,7 +1082,7 @@ CFX_QuartzDevice::~CFX_QuartzDevice() if (m_pContext) { CGContextRelease(m_pContext); } - if (GetBitmap() && m_bOwnedBitmap) { + if (m_bOwnedBitmap) { delete GetBitmap(); } } diff --git a/core/src/fxge/dib/fx_dib_engine.cpp b/core/src/fxge/dib/fx_dib_engine.cpp index 252d26d803..cb3559180f 100644 --- a/core/src/fxge/dib/fx_dib_engine.cpp +++ b/core/src/fxge/dib/fx_dib_engine.cpp @@ -679,9 +679,7 @@ CFX_ImageStretcher::~CFX_ImageStretcher() if (m_pScanline) { FX_Free(m_pScanline); } - if (m_pStretchEngine) { - delete m_pStretchEngine; - } + delete m_pStretchEngine; if (m_pMaskScanline) { FX_Free(m_pMaskScanline); } diff --git a/core/src/fxge/dib/fx_dib_main.cpp b/core/src/fxge/dib/fx_dib_main.cpp index bc5c340f65..74e9c3cfd5 100644 --- a/core/src/fxge/dib/fx_dib_main.cpp +++ b/core/src/fxge/dib/fx_dib_main.cpp @@ -48,9 +48,7 @@ CFX_DIBSource::~CFX_DIBSource() if (m_pPalette) { FX_Free(m_pPalette); } - if (m_pAlphaMask) { - delete m_pAlphaMask; - } + delete m_pAlphaMask; } CFX_DIBitmap::CFX_DIBitmap() { @@ -139,9 +137,7 @@ void CFX_DIBitmap::TakeOver(CFX_DIBitmap* pSrcBitmap) if (m_pPalette) { FX_Free(m_pPalette); } - if (m_pAlphaMask) { - delete m_pAlphaMask; - } + delete m_pAlphaMask; m_pBuffer = pSrcBitmap->m_pBuffer; m_pPalette = pSrcBitmap->m_pPalette; m_pAlphaMask = pSrcBitmap->m_pAlphaMask; @@ -1497,9 +1493,7 @@ CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) } CFX_DIBExtractor::~CFX_DIBExtractor() { - if (m_pBitmap) { - delete m_pBitmap; - } + delete m_pBitmap; } CFX_FilteredDIB::CFX_FilteredDIB() { @@ -1508,7 +1502,7 @@ CFX_FilteredDIB::CFX_FilteredDIB() } CFX_FilteredDIB::~CFX_FilteredDIB() { - if (m_pSrc && m_bAutoDropSrc) { + if (m_bAutoDropSrc) { delete m_pSrc; } if (m_pScanline) { @@ -1548,9 +1542,7 @@ CFX_ImageRenderer::CFX_ImageRenderer() } CFX_ImageRenderer::~CFX_ImageRenderer() { - if (m_pTransformer) { - delete m_pTransformer; - } + delete m_pTransformer; } extern FX_RECT _FXDIB_SwapClipBox(FX_RECT& clip, int width, int height, FX_BOOL bFlipX, FX_BOOL bFlipY); FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice, const CFX_ClipRgn* pClipRgn, @@ -1667,9 +1659,7 @@ CFX_BitmapStorer::CFX_BitmapStorer() } CFX_BitmapStorer::~CFX_BitmapStorer() { - if (m_pBitmap) { - delete m_pBitmap; - } + delete m_pBitmap; } CFX_DIBitmap* CFX_BitmapStorer::Detach() { @@ -1679,9 +1669,7 @@ CFX_DIBitmap* CFX_BitmapStorer::Detach() } void CFX_BitmapStorer::Replace(CFX_DIBitmap* pBitmap) { - if (m_pBitmap) { - delete m_pBitmap; - } + delete m_pBitmap; m_pBitmap = pBitmap; } void CFX_BitmapStorer::ComposeScanline(int line, const uint8_t* scanline, const uint8_t* scan_extra_alpha) diff --git a/core/src/fxge/ge/fx_ge.cpp b/core/src/fxge/ge/fx_ge.cpp index f91953c587..8c2a4378da 100644 --- a/core/src/fxge/ge/fx_ge.cpp +++ b/core/src/fxge/ge/fx_ge.cpp @@ -17,13 +17,9 @@ CFX_GEModule::CFX_GEModule() } CFX_GEModule::~CFX_GEModule() { - if (m_pFontCache) { - delete m_pFontCache; - } + delete m_pFontCache; m_pFontCache = NULL; - if (m_pFontMgr) { - delete m_pFontMgr; - } + delete m_pFontMgr; m_pFontMgr = NULL; DestroyPlatform(); } @@ -47,9 +43,7 @@ void CFX_GEModule::Use(CFX_GEModule* pModule) } void CFX_GEModule::Destroy() { - if (g_pGEModule) { - delete g_pGEModule; - } + delete g_pGEModule; g_pGEModule = NULL; } CFX_FontCache* CFX_GEModule::GetFontCache() diff --git a/core/src/fxge/ge/fx_ge_device.cpp b/core/src/fxge/ge/fx_ge_device.cpp index b4a4a89595..793dfc5ee2 100644 --- a/core/src/fxge/ge/fx_ge_device.cpp +++ b/core/src/fxge/ge/fx_ge_device.cpp @@ -12,15 +12,11 @@ CFX_RenderDevice::CFX_RenderDevice() } CFX_RenderDevice::~CFX_RenderDevice() { - if (m_pDeviceDriver) { - delete m_pDeviceDriver; - } + delete m_pDeviceDriver; } void CFX_RenderDevice::SetDeviceDriver(IFX_RenderDeviceDriver* pDriver) { - if (m_pDeviceDriver) { - delete m_pDeviceDriver; - } + delete m_pDeviceDriver; m_pDeviceDriver = pDriver; InitDeviceInfo(); } diff --git a/core/src/fxge/ge/fx_ge_font.cpp b/core/src/fxge/ge/fx_ge_font.cpp index c9e3e3fe1f..d04f4fd59d 100644 --- a/core/src/fxge/ge/fx_ge_font.cpp +++ b/core/src/fxge/ge/fx_ge_font.cpp @@ -64,10 +64,8 @@ FX_BOOL CFX_Font::LoadClone(const CFX_Font* pFont) } CFX_Font::~CFX_Font() { - if (m_pSubstFont) { - delete m_pSubstFont; - m_pSubstFont = NULL; - } + delete m_pSubstFont; + m_pSubstFont = NULL; if (m_bLogic) { m_OtfFontData.DetachBuffer(); return; diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp index a15f742f38..538da9ae4c 100644 --- a/core/src/fxge/ge/fx_ge_fontmap.cpp +++ b/core/src/fxge/ge/fx_ge_fontmap.cpp @@ -74,9 +74,7 @@ CFX_FontMgr::CFX_FontMgr() } CFX_FontMgr::~CFX_FontMgr() { - if (m_pBuiltinMapper) { - delete m_pBuiltinMapper; - } + delete m_pBuiltinMapper; FreeCache(); if (m_FTLibrary) { FXFT_Done_FreeType(m_FTLibrary); diff --git a/core/src/fxge/ge/fx_ge_text.cpp b/core/src/fxge/ge/fx_ge_text.cpp index 9a3b021b67..6b1f691693 100644 --- a/core/src/fxge/ge/fx_ge_text.cpp +++ b/core/src/fxge/ge/fx_ge_text.cpp @@ -1058,9 +1058,7 @@ CFX_FaceCache::~CFX_FaceCache() m_PathMap.GetNextAssoc(pos, key1, (void*&)pPath); delete pPath; } - if (m_pBitmap) { - delete m_pBitmap; - } + delete m_pBitmap; m_PathMap.RemoveAll(); } #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ diff --git a/core/src/fxge/skia/fx_skia_device.cpp b/core/src/fxge/skia/fx_skia_device.cpp index 7a8384f89c..ae6b79b686 100644 --- a/core/src/fxge/skia/fx_skia_device.cpp +++ b/core/src/fxge/skia/fx_skia_device.cpp @@ -241,7 +241,7 @@ CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap, int dither_bit } CFX_SkiaDeviceDriver::~CFX_SkiaDeviceDriver() { - if (m_pAggDriver) delete m_pAggDriver; + delete m_pAggDriver; } FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FIXFLOAT font_size, FX_DWORD color, diff --git a/core/src/fxge/win32/fx_win32_dib.cpp b/core/src/fxge/win32/fx_win32_dib.cpp index a57b04688a..b6455c3570 100644 --- a/core/src/fxge/win32/fx_win32_dib.cpp +++ b/core/src/fxge/win32/fx_win32_dib.cpp @@ -142,9 +142,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_WCHAR* filename) CFX_ByteString info = GetBitmapInfo(pDIBitmap); int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); if (!ret) { - if (pDIBitmap) { - delete pDIBitmap; - } + delete pDIBitmap; pDIBitmap = NULL; } DeleteDC(hDC); @@ -178,9 +176,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) CFX_ByteString info = GetBitmapInfo(pDIBitmap); int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); if (!ret) { - if (pDIBitmap) { - delete pDIBitmap; - } + delete pDIBitmap; pDIBitmap = NULL; } DeleteDC(hDC); @@ -255,9 +251,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, HBITMAP hBitmap, FX_DWORD* pP } } if (ret == 0) { - if (pDIBitmap) { - delete pDIBitmap; - } + delete pDIBitmap; pDIBitmap = NULL; } if (bCreatedDC) { diff --git a/core/src/fxge/win32/fx_win32_print.cpp b/core/src/fxge/win32/fx_win32_print.cpp index 74d0a3cabf..163ee84a0a 100644 --- a/core/src/fxge/win32/fx_win32_print.cpp +++ b/core/src/fxge/win32/fx_win32_print.cpp @@ -279,9 +279,7 @@ CPSPrinterDriver::CPSPrinterDriver() CPSPrinterDriver::~CPSPrinterDriver() { EndRendering(); - if (m_pPSOutput) { - delete m_pPSOutput; - } + delete m_pPSOutput; } FX_BOOL CPSPrinterDriver::Init(HDC hDC, int pslevel, FX_BOOL bCmykOutput) { |