summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi
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/fpdfapi
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/fpdfapi')
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp10
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font.cpp8
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp16
-rw-r--r--core/src/fpdfapi/fpdf_font/ttgsubtable.h12
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp16
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp8
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp8
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp8
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp12
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp14
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp12
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp26
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp16
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp4
16 files changed, 50 insertions, 128 deletions
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index b7eb05f452..22826a3609 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -1967,10 +1967,8 @@ int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause *pPause)
}
void CPDF_Creator::Clear()
{
- if (m_pXRefStream) {
- delete m_pXRefStream;
- m_pXRefStream = NULL;
- }
+ delete m_pXRefStream;
+ m_pXRefStream = NULL;
m_File.Clear();
m_NewObjNumArray.RemoveAll();
if (m_pIDArray) {
@@ -2068,7 +2066,7 @@ void CPDF_Creator::InitID(FX_BOOL bDefault )
CFX_ByteString user_pass = m_pParser->GetPassword();
FX_DWORD flag = PDF_ENCRYPT_CONTENT;
handler.OnCreate(m_pEncryptDict, m_pIDArray, (const uint8_t*)user_pass, user_pass.GetLength(), flag);
- if (m_pCryptoHandler && m_bNewCrypto) {
+ if (m_bNewCrypto) {
delete m_pCryptoHandler;
}
m_pCryptoHandler = new CPDF_StandardCryptoHandler;
@@ -2122,7 +2120,7 @@ void CPDF_Creator::RemoveSecurity()
}
void CPDF_Creator::ResetStandardSecurity()
{
- if ((m_bStandardSecurity || m_bNewCrypto) && m_pCryptoHandler) {
+ if (m_bStandardSecurity || m_bNewCrypto) {
delete m_pCryptoHandler;
m_pCryptoHandler = NULL;
}
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
index 784fc0169e..2db8d6095f 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
@@ -1044,9 +1044,7 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert)
}
}
}
- if (pEncoding) {
- delete pEncoding;
- }
+ delete pEncoding;
pFontDesc->SetAtInteger("StemV", nStemV);
AddIndirectObject(pFontDesc);
pFontDict->SetAtReference("FontDescriptor", this, pFontDesc);
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
index 14207f7e6b..e7072e8d55 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -1744,10 +1744,6 @@ CPDF_Type3Char::CPDF_Type3Char()
}
CPDF_Type3Char::~CPDF_Type3Char()
{
- if (m_pForm) {
- delete m_pForm;
- }
- if (m_pBitmap) {
- delete m_pBitmap;
- }
+ delete m_pForm;
+ delete m_pBitmap;
}
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index 0b4064b3c6..7dd019da85 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -300,9 +300,7 @@ CPDF_CMap::~CPDF_CMap()
if (m_pLeadingBytes) {
FX_Free(m_pLeadingBytes);
}
- if (m_pUseMap) {
- delete m_pUseMap;
- }
+ delete m_pUseMap;
}
void CPDF_CMap::Release()
{
@@ -710,15 +708,9 @@ CPDF_CIDFont::~CPDF_CIDFont()
if (m_pAnsiWidths) {
FX_Free(m_pAnsiWidths);
}
- if (m_pAllocatedCMap) {
- delete m_pAllocatedCMap;
- }
- if (m_pCIDToGIDMap) {
- delete m_pCIDToGIDMap;
- }
- if (m_pTTGSUBTable) {
- delete m_pTTGSUBTable;
- }
+ delete m_pAllocatedCMap;
+ delete m_pCIDToGIDMap;
+ delete m_pTTGSUBTable;
}
FX_WORD CPDF_CIDFont::CIDFromCharCode(FX_DWORD charcode) const
{
diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.h b/core/src/fpdfapi/fpdf_font/ttgsubtable.h
index 69ccc3e453..1b18f82d6e 100644
--- a/core/src/fpdfapi/fpdf_font/ttgsubtable.h
+++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.h
@@ -282,9 +282,7 @@ private:
}
~TSingleSubstFormat1()
{
- if(Coverage) {
- delete Coverage;
- }
+ delete Coverage;
}
private:
TSingleSubstFormat1(const TSingleSubstFormat1&);
@@ -300,12 +298,8 @@ private:
}
~TSingleSubstFormat2()
{
- if(Coverage) {
- delete Coverage;
- }
- if(Substitute) {
- delete[] Substitute;
- }
+ delete Coverage;
+ delete[] Substitute;
}
private:
TSingleSubstFormat2(const TSingleSubstFormat2&);
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index 85c785fd22..db3966ec17 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -697,9 +697,7 @@ void CPDF_ShadingObject::CalcBoundingBox()
}
CPDF_FormObject::~CPDF_FormObject()
{
- if (m_pForm) {
- delete m_pForm;
- }
+ delete m_pForm;
}
void CPDF_FormObject::Transform(const CFX_AffineMatrix& matrix)
{
@@ -709,9 +707,7 @@ void CPDF_FormObject::Transform(const CFX_AffineMatrix& matrix)
void CPDF_FormObject::CopyData(const CPDF_PageObject* pSrc)
{
const CPDF_FormObject* pSrcObj = (const CPDF_FormObject*)pSrc;
- if (m_pForm) {
- delete m_pForm;
- }
+ delete m_pForm;
m_pForm = pSrcObj->m_pForm->Clone();
m_FormMatrix = pSrcObj->m_FormMatrix;
}
@@ -735,9 +731,7 @@ CPDF_PageObjects::CPDF_PageObjects(FX_BOOL bReleaseMembers) : m_ObjectList(128)
}
CPDF_PageObjects::~CPDF_PageObjects()
{
- if (m_pParser) {
- delete m_pParser;
- }
+ delete m_pParser;
if (!m_bReleaseMembers) {
return;
}
@@ -851,9 +845,7 @@ void CPDF_PageObjects::LoadTransInfo()
void CPDF_PageObjects::ClearCacheObjects()
{
m_ParseState = PDF_CONTENT_NOT_PARSED;
- if (m_pParser) {
- delete m_pParser;
- }
+ delete m_pParser;
m_pParser = NULL;
if (m_bReleaseMembers) {
FX_POSITION pos = m_ObjectList.GetHeadPosition();
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
index 1146d76695..0ee7a0da7d 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
@@ -930,9 +930,7 @@ CPDF_SeparationCS::~CPDF_SeparationCS()
if (m_pAltCS) {
m_pAltCS->ReleaseCS();
}
- if (m_pFunc) {
- delete m_pFunc;
- }
+ delete m_pFunc;
}
void CPDF_SeparationCS::GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOAT& max) const
{
@@ -1020,9 +1018,7 @@ public:
};
CPDF_DeviceNCS::~CPDF_DeviceNCS()
{
- if (m_pFunc) {
- delete m_pFunc;
- }
+ delete m_pFunc;
if (m_pAltCS) {
m_pAltCS->ReleaseCS();
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
index 6362be973b..f115b6770d 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
@@ -460,9 +460,7 @@ CPDF_SampledFunc::CPDF_SampledFunc()
}
CPDF_SampledFunc::~CPDF_SampledFunc()
{
- if (m_pSampleStream) {
- delete m_pSampleStream;
- }
+ delete m_pSampleStream;
if (m_pEncodeInfo) {
FX_Free(m_pEncodeInfo);
}
@@ -713,9 +711,7 @@ CPDF_StitchFunc::CPDF_StitchFunc()
CPDF_StitchFunc::~CPDF_StitchFunc()
{
for (int i = 0; i < m_nSubs; i ++)
- if (m_pSubFunctions[i]) {
- delete m_pSubFunctions[i];
- }
+ delete m_pSubFunctions[i];
if (m_pSubFunctions) {
FX_Free(m_pSubFunctions);
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
index e2d075e02c..70d0743f58 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
@@ -38,9 +38,7 @@ CPDF_ClipPathData::~CPDF_ClipPathData()
FX_Free(m_pTypeList);
}
for (i = m_TextCount - 1; i > -1; i --)
- if (m_pTextList[i]) {
- delete m_pTextList[i];
- }
+ delete m_pTextList[i];
if (m_pTextList) {
FX_Free(m_pTextList);
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 5f4023a278..fdc4a27989 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -44,9 +44,7 @@ CPDF_StreamContentParser::~CPDF_StreamContentParser()
if (m_pPathPoints) {
FX_Free(m_pPathPoints);
}
- if (m_pCurStates) {
- delete m_pCurStates;
- }
+ delete m_pCurStates;
if (m_pLastImageDict) {
m_pLastImageDict->Release();
}
@@ -801,9 +799,7 @@ void CPDF_StreamContentParser::Handle_EndText()
if (m_pCurStates->m_TextState.GetObject()->m_TextMode < 4) {
for (int i = 0; i < count; i ++) {
CPDF_TextObject* pText = (CPDF_TextObject*)m_ClipTextList.GetAt(i);
- if (pText) {
- delete pText;
- }
+ delete pText;
}
} else {
m_pCurStates->m_ClipPath.AppendTexts((CPDF_TextObject**)m_ClipTextList.GetData(), count);
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index 6f0996977f..ff1f6c4aa0 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -918,17 +918,11 @@ CPDF_ContentParser::~CPDF_ContentParser()
}
void CPDF_ContentParser::Clear()
{
- if (m_pParser) {
- delete m_pParser;
- }
- if (m_pSingleStream) {
- delete m_pSingleStream;
- }
+ delete m_pParser;
+ delete m_pSingleStream;
if (m_pStreamArray) {
for (FX_DWORD i = 0; i < m_nStreams; i ++)
- if (m_pStreamArray[i]) {
- delete m_pStreamArray[i];
- }
+ delete m_pStreamArray[i];
FX_Free(m_pStreamArray);
}
if (m_pData && m_pSingleStream == NULL) {
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
index bd53874af4..48b3a40495 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
@@ -34,10 +34,8 @@ CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc, CPDF_Object* pPatter
}
CPDF_TilingPattern::~CPDF_TilingPattern()
{
- if (m_pForm) {
- delete m_pForm;
- m_pForm = NULL;
- }
+ delete m_pForm;
+ m_pForm = NULL;
}
FX_BOOL CPDF_TilingPattern::Load()
{
@@ -92,9 +90,7 @@ CPDF_ShadingPattern::~CPDF_ShadingPattern()
void CPDF_ShadingPattern::Clear()
{
for (int i = 0; i < m_nFuncs; i ++) {
- if (m_pFunctions[i]) {
- delete m_pFunctions[i];
- }
+ delete m_pFunctions[i];
m_pFunctions[i] = NULL;
}
CPDF_ColorSpace* pCS = m_pCountedCS ? m_pCountedCS->get() : NULL;
@@ -117,9 +113,7 @@ FX_BOOL CPDF_ShadingPattern::Load()
}
if (m_nFuncs) {
for (int i = 0; i < m_nFuncs; i ++)
- if (m_pFunctions[i]) {
- delete m_pFunctions[i];
- }
+ delete m_pFunctions[i];
m_nFuncs = 0;
}
CPDF_Object* pFunc = pShadingDict->GetElementValue(FX_BSTRC("Function"));
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp
index ac48dc6c65..efe085c2ee 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp
@@ -18,9 +18,7 @@ CFX_DataFilter::CFX_DataFilter()
}
CFX_DataFilter::~CFX_DataFilter()
{
- if (m_pDestFilter) {
- delete m_pDestFilter;
- }
+ delete m_pDestFilter;
}
void CFX_DataFilter::SetDestFilter(CFX_DataFilter* pFilter)
{
@@ -192,12 +190,8 @@ CPDF_StreamFilter* CPDF_Stream::GetStreamFilter(FX_BOOL bRaw) const
}
CPDF_StreamFilter::~CPDF_StreamFilter()
{
- if (m_pFilter) {
- delete m_pFilter;
- }
- if (m_pBuffer) {
- delete m_pBuffer;
- }
+ delete m_pFilter;
+ delete m_pBuffer;
}
#define FPDF_FILTER_BUFFER_IN_SIZE FPDF_FILTER_BUFFER_SIZE
FX_DWORD CPDF_StreamFilter::ReadBlock(uint8_t* buffer, FX_DWORD buf_size)
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index 56df7f3a0c..685ee047aa 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -68,7 +68,7 @@ void CPDF_Parser::SetEncryptDictionary(CPDF_Dictionary* pDict)
void CPDF_Parser::CloseParser(FX_BOOL bReParse)
{
m_bVersionUpdated = FALSE;
- if (m_pDocument && !bReParse) {
+ if (!bReParse) {
delete m_pDocument;
m_pDocument = NULL;
}
@@ -309,11 +309,9 @@ FX_DWORD CPDF_Parser::SetEncryptHandler()
}
void CPDF_Parser::ReleaseEncryptHandler()
{
- if (m_Syntax.m_pCryptoHandler) {
- delete m_Syntax.m_pCryptoHandler;
- m_Syntax.m_pCryptoHandler = NULL;
- }
- if (m_pSecurityHandler && !m_bForceUseSecurityHandler) {
+ delete m_Syntax.m_pCryptoHandler;
+ m_Syntax.m_pCryptoHandler = NULL;
+ if (!m_bForceUseSecurityHandler) {
delete m_pSecurityHandler;
m_pSecurityHandler = NULL;
}
@@ -1482,7 +1480,7 @@ FX_BOOL CPDF_Parser::IsOwner()
void CPDF_Parser::SetSecurityHandler(CPDF_SecurityHandler* pSecurityHandler, FX_BOOL bForced)
{
ASSERT(m_pSecurityHandler == NULL);
- if (m_pSecurityHandler && !m_bForceUseSecurityHandler) {
+ if (!m_bForceUseSecurityHandler) {
delete m_pSecurityHandler;
m_pSecurityHandler = NULL;
}
@@ -2984,12 +2982,8 @@ CPDF_DataAvail::~CPDF_DataAvail()
if (m_pTrailer) {
m_pTrailer->Release();
}
- if (m_pageMapCheckState) {
- delete m_pageMapCheckState;
- }
- if (m_pagesLoadState) {
- delete m_pagesLoadState;
- }
+ delete m_pageMapCheckState;
+ delete m_pagesLoadState;
int32_t i = 0;
int32_t iSize = m_arrayAcroforms.GetSize();
for (i = 0; i < iSize; ++i) {
@@ -4640,10 +4634,8 @@ CPDF_PageNode::~CPDF_PageNode()
{
int32_t iSize = m_childNode.GetSize();
for (int32_t i = 0; i < iSize; ++i) {
- CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i];
- if (pNode) {
- delete pNode;
- }
+ CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i];
+ delete pNode;
}
m_childNode.RemoveAll();
}
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp
index 6a876a2390..cdbecd65ea 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp
@@ -188,20 +188,14 @@ CPDF_ImageCache::CPDF_ImageCache(CPDF_Document* pDoc, CPDF_Stream* pStream)
}
CPDF_ImageCache::~CPDF_ImageCache()
{
- if (m_pCachedBitmap) {
- delete m_pCachedBitmap;
- m_pCachedBitmap = NULL;
- }
- if (m_pCachedMask) {
- delete m_pCachedMask;
- m_pCachedMask = NULL;
- }
+ delete m_pCachedBitmap;
+ m_pCachedBitmap = NULL;
+ delete m_pCachedMask;
+ m_pCachedMask = NULL;
}
void CPDF_ImageCache::Reset(const CFX_DIBitmap* pBitmap)
{
- if (m_pCachedBitmap) {
- delete m_pCachedBitmap;
- }
+ delete m_pCachedBitmap;
m_pCachedBitmap = NULL;
if (pBitmap) {
m_pCachedBitmap = pBitmap->Clone();
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
index 5748e23efe..3ee2222d8b 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
@@ -994,9 +994,7 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, CPDF_Pag
m_pDevice->RestoreState();
}
m_pDevice->RestoreState();
- if (pStates) {
- delete pStates;
- }
+ delete pStates;
return;
}
if (bAligned) {