From cb62e7657b3a9a04142028a4e6614029a08e894b Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 14 Aug 2015 15:45:39 -0700 Subject: Don't bother checking pointers before delete[] and FX_Free(). R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1297713003 . --- core/src/fxcodec/codec/codec_int.h | 4 +--- core/src/fxcodec/codec/fx_codec.cpp | 8 ++------ core/src/fxcodec/codec/fx_codec_fax.cpp | 16 ++++------------ core/src/fxcodec/codec/fx_codec_flate.cpp | 16 ++++------------ core/src/fxcodec/codec/fx_codec_icc.cpp | 4 +--- core/src/fxcodec/codec/fx_codec_jbig.cpp | 12 +++--------- core/src/fxcodec/codec/fx_codec_jpeg.cpp | 8 ++------ 7 files changed, 17 insertions(+), 51 deletions(-) (limited to 'core/src/fxcodec') diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h index 9fe77a44f7..e7baa585f9 100644 --- a/core/src/fxcodec/codec/codec_int.h +++ b/core/src/fxcodec/codec/codec_int.h @@ -54,9 +54,7 @@ class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder { int GetBPC() override { return m_bpc; } FX_BOOL IsColorTransformed() override { return m_bColorTransformed; } void ClearImageData() override { - if (m_pDataCache) { - FX_Free(m_pDataCache); - } + FX_Free(m_pDataCache); m_pDataCache = NULL; } diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp index 4ed02dc2c0..0d89ea6e98 100644 --- a/core/src/fxcodec/codec/fx_codec.cpp +++ b/core/src/fxcodec/codec/fx_codec.cpp @@ -20,9 +20,7 @@ CCodec_ScanlineDecoder::CCodec_ScanlineDecoder() { m_pLastScanline = NULL; } CCodec_ScanlineDecoder::~CCodec_ScanlineDecoder() { - if (m_pDataCache) { - FX_Free(m_pDataCache); - } + FX_Free(m_pDataCache); } uint8_t* CCodec_ScanlineDecoder::GetScanline(int line) { if (m_pDataCache && line < m_pDataCache->m_nCachedLines) { @@ -254,9 +252,7 @@ CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder() m_bEOD(FALSE), m_Operator(0) {} CCodec_RLScanlineDecoder::~CCodec_RLScanlineDecoder() { - if (m_pScanline) { - FX_Free(m_pScanline); - } + FX_Free(m_pScanline); } FX_BOOL CCodec_RLScanlineDecoder::CheckDestSize() { FX_DWORD i = 0; diff --git a/core/src/fxcodec/codec/fx_codec_fax.cpp b/core/src/fxcodec/codec/fx_codec_fax.cpp index 34c07ac484..63a45c7aea 100644 --- a/core/src/fxcodec/codec/fx_codec_fax.cpp +++ b/core/src/fxcodec/codec/fx_codec_fax.cpp @@ -491,12 +491,8 @@ CCodec_FaxDecoder::CCodec_FaxDecoder() { m_pRefBuf = NULL; } CCodec_FaxDecoder::~CCodec_FaxDecoder() { - if (m_pScanlineBuf) { - FX_Free(m_pScanlineBuf); - } - if (m_pRefBuf) { - FX_Free(m_pRefBuf); - } + FX_Free(m_pScanlineBuf); + FX_Free(m_pRefBuf); } FX_BOOL CCodec_FaxDecoder::Create(const uint8_t* src_buf, FX_DWORD src_size, @@ -770,12 +766,8 @@ CCodec_FaxEncoder::CCodec_FaxEncoder(const uint8_t* src_buf, m_DestBuf.EstimateSize(0, 10240); } CCodec_FaxEncoder::~CCodec_FaxEncoder() { - if (m_pRefLine) { - FX_Free(m_pRefLine); - } - if (m_pLineBuf) { - FX_Free(m_pLineBuf); - } + FX_Free(m_pRefLine); + FX_Free(m_pLineBuf); } void CCodec_FaxEncoder::Encode(uint8_t*& dest_buf, FX_DWORD& dest_size) { int dest_bitpos = 0; diff --git a/core/src/fxcodec/codec/fx_codec_flate.cpp b/core/src/fxcodec/codec/fx_codec_flate.cpp index a4b37c1ca3..e8878e4535 100644 --- a/core/src/fxcodec/codec/fx_codec_flate.cpp +++ b/core/src/fxcodec/codec/fx_codec_flate.cpp @@ -647,18 +647,10 @@ CCodec_FlateScanlineDecoder::CCodec_FlateScanlineDecoder() { m_LeftOver = 0; } CCodec_FlateScanlineDecoder::~CCodec_FlateScanlineDecoder() { - if (m_pScanline) { - FX_Free(m_pScanline); - } - if (m_pLastLine) { - FX_Free(m_pLastLine); - } - if (m_pPredictBuffer) { - FX_Free(m_pPredictBuffer); - } - if (m_pPredictRaw) { - FX_Free(m_pPredictRaw); - } + FX_Free(m_pScanline); + FX_Free(m_pLastLine); + FX_Free(m_pPredictBuffer); + FX_Free(m_pPredictRaw); if (m_pFlate) { FPDFAPI_FlateEnd(m_pFlate); } diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp index 856766e4ea..dad880a936 100644 --- a/core/src/fxcodec/codec/fx_codec_icc.cpp +++ b/core/src/fxcodec/codec/fx_codec_icc.cpp @@ -392,9 +392,7 @@ CFX_IccTransformCache::~CFX_IccTransformCache() { if (m_pIccTransform) { cmsDeleteTransform(m_pIccTransform); } - if (m_pCmm) { - FX_Free(m_pCmm); - } + FX_Free(m_pCmm); } void CFX_IccTransformCache::Purge() {} class CFX_ByteStringKey : public CFX_BinaryBuf { diff --git a/core/src/fxcodec/codec/fx_codec_jbig.cpp b/core/src/fxcodec/codec/fx_codec_jbig.cpp index 9d78bba3bb..1551060b60 100644 --- a/core/src/fxcodec/codec/fx_codec_jbig.cpp +++ b/core/src/fxcodec/codec/fx_codec_jbig.cpp @@ -82,9 +82,7 @@ FX_BOOL CCodec_Jbig2Module::Decode(IFX_FileRead* file_ptr, FX_Free(src_buf); return TRUE; failed: - if (src_buf) { - FX_Free(src_buf); - } + FX_Free(src_buf); return FALSE; } FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, @@ -188,9 +186,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, FX_Free(m_pJbig2Context->m_src_buf); return FXCODEC_STATUS_DECODE_FINISH; failed: - if (m_pJbig2Context->m_src_buf) { - FX_Free(m_pJbig2Context->m_src_buf); - } + FX_Free(m_pJbig2Context->m_src_buf); m_pJbig2Context->m_src_buf = NULL; return FXCODEC_STATUS_ERROR; } @@ -206,9 +202,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); m_pJbig2Context->m_pContext = NULL; if (ret != JBIG2_SUCCESS) { - if (m_pJbig2Context->m_src_buf) { - FX_Free(m_pJbig2Context->m_src_buf); - } + FX_Free(m_pJbig2Context->m_src_buf); m_pJbig2Context->m_src_buf = NULL; return FXCODEC_STATUS_ERROR; } diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp index 779e7f6b37..7e95bd358f 100644 --- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp @@ -221,9 +221,7 @@ static void _JpegEncode(const CFX_DIBSource* pSource, } jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); - if (line_buf) { - FX_Free(line_buf); - } + FX_Free(line_buf); dest_size = dest_buf_length - (FX_STRSIZE)dest.free_in_buffer; } static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf, @@ -345,9 +343,7 @@ CCodec_JpegDecoder::~CCodec_JpegDecoder() { m_pExtProvider->DestroyDecoder(m_pExtContext); return; } - if (m_pScanlineBuf) { - FX_Free(m_pScanlineBuf); - } + FX_Free(m_pScanlineBuf); if (m_bInited) { jpeg_destroy_decompress(&cinfo); } -- cgit v1.2.3