summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_page
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-06-19 17:26:17 -0700
committerLei Zhang <thestig@chromium.org>2015-06-19 17:26:17 -0700
commit6d8b1c2c7b1cbada20109f70ae971a4192330bb5 (patch)
treee755b7cb2624622cba606134493d25fb7f1ce6c8 /core/src/fpdfapi/fpdf_page
parent9883a7da2d4f31910073c03e703d5b97a45d9254 (diff)
downloadpdfium-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/fpdfapi/fpdf_page')
-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
7 files changed, 18 insertions, 52 deletions
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"));