summaryrefslogtreecommitdiff
path: root/core/src/fxcodec
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 /core/src/fxcodec
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 'core/src/fxcodec')
-rw-r--r--core/src/fxcodec/codec/fx_codec_icc.cpp8
-rw-r--r--core/src/fxcodec/jbig2/JBig2_Context.cpp170
-rw-r--r--core/src/fxcodec/jbig2/JBig2_PatternDict.cpp4
-rw-r--r--core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp4
4 files changed, 47 insertions, 139 deletions
diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp
index 703d00a496..da503c03fd 100644
--- a/core/src/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/src/fxcodec/codec/fx_codec_icc.cpp
@@ -514,17 +514,13 @@ CCodec_IccModule::~CCodec_IccModule()
CFX_IccProfileCache* pProfileCache;
while (pos) {
m_MapProfile.GetNextAssoc(pos, key, (void*&)pProfileCache);
- if (pProfileCache) {
- delete pProfileCache;
- }
+ delete pProfileCache;
}
pos = m_MapTranform.GetStartPosition();
CFX_IccTransformCache* pTransformCache;
while (pos) {
m_MapTranform.GetNextAssoc(pos, key, (void*&)pTransformCache);
- if (pTransformCache) {
- delete pTransformCache;
- }
+ delete pTransformCache;
}
}
void* CCodec_IccModule::CreateTransform_sRGB(const uint8_t* pProfileData, FX_DWORD dwProfileSize, int32_t& nComponents, int32_t intent, FX_DWORD dwSrcFormat)
diff --git a/core/src/fxcodec/jbig2/JBig2_Context.cpp b/core/src/fxcodec/jbig2/JBig2_Context.cpp
index f58b7f36f5..41a3cced8c 100644
--- a/core/src/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_Context.cpp
@@ -30,9 +30,7 @@ CJBig2_Context *CJBig2_Context::CreateContext(CJBig2_Module *pModule, uint8_t *p
}
void CJBig2_Context::DestroyContext(CJBig2_Context *pContext)
{
- if(pContext) {
- delete pContext;
- }
+ delete pContext;
}
CJBig2_Context::CJBig2_Context(uint8_t *pGlobalData, FX_DWORD dwGlobalLength,
uint8_t *pData, FX_DWORD dwLength, int32_t nStreamType, std::list<CJBig2_CachePair>* pSymbolDictCache, IFX_Pause* pPause)
@@ -63,37 +61,25 @@ CJBig2_Context::CJBig2_Context(uint8_t *pGlobalData, FX_DWORD dwGlobalLength,
}
CJBig2_Context::~CJBig2_Context()
{
- if(m_pArithDecoder) {
- delete m_pArithDecoder;
- }
+ delete m_pArithDecoder;
m_pArithDecoder = NULL;
- if(m_pGRD) {
- delete m_pGRD;
- }
+ delete m_pGRD;
m_pGRD = NULL;
if(m_gbContext) {
m_pModule->JBig2_Free(m_gbContext);
}
m_gbContext = NULL;
- if(m_pGlobalContext) {
- delete m_pGlobalContext;
- }
+ delete m_pGlobalContext;
m_pGlobalContext = NULL;
- if(m_pPageInfoList) {
- delete m_pPageInfoList;
- }
+ delete m_pPageInfoList;
m_pPageInfoList = NULL;
- if(m_bBufSpecified && m_pPage) {
+ if(m_bBufSpecified) {
delete m_pPage;
}
m_pPage = NULL;
- if(m_pStream) {
- delete m_pStream;
- }
+ delete m_pStream;
m_pStream = NULL;
- if(m_pSegmentList) {
- delete m_pSegmentList;
- }
+ delete m_pSegmentList;
m_pSegmentList = NULL;
}
int32_t CJBig2_Context::decodeFile(IFX_Pause* pPause)
@@ -247,9 +233,7 @@ int32_t CJBig2_Context::getFirstPage(uint8_t *pBuf, int32_t width, int32_t heigh
}
m_bFirstPage = TRUE;
m_PauseStep = 0;
- if(m_pPage) {
- delete m_pPage;
- }
+ delete m_pPage;
JBIG2_ALLOC(m_pPage, CJBig2_Image(width, height, stride, pBuf));
m_bBufSpecified = TRUE;
if(m_pPage && pPause && pPause->NeedToPauseNow()) {
@@ -316,9 +300,7 @@ int32_t CJBig2_Context::getNextPage(uint8_t *pBuf, int32_t width, int32_t height
int32_t nRet = JBIG2_ERROR_STREAM_TYPE;
m_bFirstPage = FALSE;
m_PauseStep = 0;
- if(m_pPage) {
- delete m_pPage;
- }
+ delete m_pPage;
JBIG2_ALLOC(m_pPage, CJBig2_Image(width, height, stride, pBuf));
m_bBufSpecified = TRUE;
if(m_pPage && pPause && pPause->NeedToPauseNow()) {
@@ -571,9 +553,7 @@ int32_t CJBig2_Context::ProcessiveParseSegmentData(CJBig2_Segment *pSegment, IFX
pPageInfo->m_bIsStriped = 1;
}
if(!m_bBufSpecified) {
- if(m_pPage) {
- delete m_pPage;
- }
+ delete m_pPage;
if(pPageInfo->m_dwHeight == 0xffffffff) {
JBIG2_ALLOC(m_pPage, CJBig2_Image(pPageInfo->m_dwWidth, pPageInfo->m_wMaxStripeSize));
} else {
@@ -860,21 +840,11 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment *pSegment, IFX_Pause* pPa
if(SDINSYMS) {
m_pModule->JBig2_Free(SDINSYMS);
}
- if(Table_B1) {
- delete Table_B1;
- }
- if(Table_B2) {
- delete Table_B2;
- }
- if(Table_B3) {
- delete Table_B3;
- }
- if(Table_B4) {
- delete Table_B4;
- }
- if(Table_B5) {
- delete Table_B5;
- }
+ delete Table_B1;
+ delete Table_B2;
+ delete Table_B3;
+ delete Table_B4;
+ delete Table_B5;
if(bUsed == FALSE) {
if(gbContext) {
m_pModule->JBig2_Free(gbContext);
@@ -889,21 +859,11 @@ failed:
if(SDINSYMS) {
m_pModule->JBig2_Free(SDINSYMS);
}
- if(Table_B1) {
- delete Table_B1;
- }
- if(Table_B2) {
- delete Table_B2;
- }
- if(Table_B3) {
- delete Table_B3;
- }
- if(Table_B4) {
- delete Table_B4;
- }
- if(Table_B5) {
- delete Table_B5;
- }
+ delete Table_B1;
+ delete Table_B2;
+ delete Table_B3;
+ delete Table_B4;
+ delete Table_B5;
if(gbContext) {
m_pModule->JBig2_Free(gbContext);
}
@@ -1242,39 +1202,17 @@ FX_BOOL CJBig2_Context::parseTextRegion(CJBig2_Segment *pSegment)
if(grContext) {
m_pModule->JBig2_Free(grContext);
}
- if(Table_B1) {
- delete Table_B1;
- }
- if(Table_B6) {
- delete Table_B6;
- }
- if(Table_B7) {
- delete Table_B7;
- }
- if(Table_B8) {
- delete Table_B8;
- }
- if(Table_B9) {
- delete Table_B9;
- }
- if(Table_B10) {
- delete Table_B10;
- }
- if(Table_B11) {
- delete Table_B11;
- }
- if(Table_B12) {
- delete Table_B12;
- }
- if(Table_B13) {
- delete Table_B13;
- }
- if(Table_B14) {
- delete Table_B14;
- }
- if(Table_B15) {
- delete Table_B15;
- }
+ delete Table_B1;
+ delete Table_B6;
+ delete Table_B7;
+ delete Table_B8;
+ delete Table_B9;
+ delete Table_B10;
+ delete Table_B11;
+ delete Table_B12;
+ delete Table_B13;
+ delete Table_B14;
+ delete Table_B15;
return JBIG2_SUCCESS;
failed:
delete pTRD;
@@ -1287,39 +1225,17 @@ failed:
if(grContext) {
m_pModule->JBig2_Free(grContext);
}
- if(Table_B1) {
- delete Table_B1;
- }
- if(Table_B6) {
- delete Table_B6;
- }
- if(Table_B7) {
- delete Table_B7;
- }
- if(Table_B8) {
- delete Table_B8;
- }
- if(Table_B9) {
- delete Table_B9;
- }
- if(Table_B10) {
- delete Table_B10;
- }
- if(Table_B11) {
- delete Table_B11;
- }
- if(Table_B12) {
- delete Table_B12;
- }
- if(Table_B13) {
- delete Table_B13;
- }
- if(Table_B14) {
- delete Table_B14;
- }
- if(Table_B15) {
- delete Table_B15;
- }
+ delete Table_B1;
+ delete Table_B6;
+ delete Table_B7;
+ delete Table_B8;
+ delete Table_B9;
+ delete Table_B10;
+ delete Table_B11;
+ delete Table_B12;
+ delete Table_B13;
+ delete Table_B14;
+ delete Table_B15;
return nRet;
}
diff --git a/core/src/fxcodec/jbig2/JBig2_PatternDict.cpp b/core/src/fxcodec/jbig2/JBig2_PatternDict.cpp
index 0c6e5be8ce..df45288812 100644
--- a/core/src/fxcodec/jbig2/JBig2_PatternDict.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_PatternDict.cpp
@@ -15,9 +15,7 @@ CJBig2_PatternDict::~CJBig2_PatternDict()
{
if(HDPATS) {
for(FX_DWORD i = 0; i < NUMPATS; i++) {
- if(HDPATS[i]) {
- delete HDPATS[i];
- }
+ delete HDPATS[i];
}
m_pModule->JBig2_Free(HDPATS);
}
diff --git a/core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp b/core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp
index e9bb9c62e0..0e5b92ff5a 100644
--- a/core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp
@@ -41,9 +41,7 @@ CJBig2_SymbolDict::~CJBig2_SymbolDict()
{
if(SDEXSYMS) {
for(FX_DWORD i = 0; i < SDNUMEXSYMS; i++) {
- if(SDEXSYMS[i]) {
- delete SDEXSYMS[i];
- }
+ delete SDEXSYMS[i];
}
m_pModule->JBig2_Free(SDEXSYMS);
}