summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-08-14 22:22:13 -0700
committerLei Zhang <thestig@chromium.org>2015-08-14 22:22:13 -0700
commitda180e9fdd4385df024cc18046f62ca47bc74d74 (patch)
tree931e0e64ac2cbc82e3718e43418ee6bd676da4a5 /core/src/fpdfapi
parent2b1a2d528469cda4e9f3e36d3c7a649e0d476480 (diff)
downloadpdfium-da180e9fdd4385df024cc18046f62ca47bc74d74.tar.xz
Merge to XFA: Don't bother checking pointers before delete[] and FX_Free().
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1297713003 . (cherry picked from commit cb62e7657b3a9a04142028a4e6614029a08e894b) Review URL: https://codereview.chromium.org/1287053005 .
Diffstat (limited to 'core/src/fpdfapi')
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp6
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp10
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp12
-rw-r--r--core/src/fpdfapi/fpdf_font/ttgsubtable.h60
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp34
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp16
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp34
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp12
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp12
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp9
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp16
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp9
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp12
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp4
16 files changed, 64 insertions, 190 deletions
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index ff0539c61f..668c70b243 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -403,7 +403,7 @@ CPDF_FlateEncoder::~CPDF_FlateEncoder() {
if (m_bCloned && m_pDict) {
m_pDict->Release();
}
- if (m_bNewData && m_pData) {
+ if (m_bNewData) {
FX_Free(m_pData);
}
}
@@ -2054,9 +2054,7 @@ void CPDF_Creator::InitID(FX_BOOL bDefault) {
CFX_ByteStringC bsBuffer((const uint8_t*)pBuffer, 4 * sizeof(FX_DWORD));
m_pIDArray->Add(CPDF_String::Create(bsBuffer, TRUE), m_pDocument);
}
- if (pBuffer) {
- FX_Free(pBuffer);
- }
+ FX_Free(pBuffer);
}
if (!bDefault) {
return;
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp
index 9ea94bdd00..488d8393c7 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp
@@ -278,10 +278,8 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap,
pDict->Release();
pDict = NULL;
}
- if (dest_buf) {
- FX_Free(dest_buf);
- dest_buf = NULL;
- }
+ FX_Free(dest_buf);
+ dest_buf = NULL;
dest_size = 0;
delete pNewBitmap;
return;
@@ -380,9 +378,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap,
m_bIsMask = pBitmap->IsAlphaMask();
m_Width = BitmapWidth;
m_Height = BitmapHeight;
- if (dest_buf) {
- FX_Free(dest_buf);
- }
+ FX_Free(dest_buf);
}
void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) {
pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap);
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
index 0107000dd9..8eae7cf3f8 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -30,9 +30,7 @@ CPDF_FontGlobals::CPDF_FontGlobals() : m_pContrastRamps(NULL) {
}
CPDF_FontGlobals::~CPDF_FontGlobals() {
ClearAll();
- if (m_pContrastRamps) {
- FX_Free(m_pContrastRamps);
- }
+ FX_Free(m_pContrastRamps);
}
class CFX_StockFontArray {
public:
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index 3c8b2567fe..6c728242e6 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -301,15 +301,9 @@ CPDF_CMap::CPDF_CMap() {
m_nCodeRanges = 0;
}
CPDF_CMap::~CPDF_CMap() {
- if (m_pMapping) {
- FX_Free(m_pMapping);
- }
- if (m_pAddMapping) {
- FX_Free(m_pAddMapping);
- }
- if (m_pLeadingBytes) {
- FX_Free(m_pLeadingBytes);
- }
+ FX_Free(m_pMapping);
+ FX_Free(m_pAddMapping);
+ FX_Free(m_pLeadingBytes);
delete m_pUseMap;
}
void CPDF_CMap::Release() {
diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.h b/core/src/fpdfapi/fpdf_font/ttgsubtable.h
index 78de3f0a28..395544ddbf 100644
--- a/core/src/fpdfapi/fpdf_font/ttgsubtable.h
+++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.h
@@ -49,11 +49,7 @@ class CFX_CTTGSUBTable {
ReqFeatureIndex(0),
FeatureCount(0),
FeatureIndex(NULL) {}
- ~TLangSys() {
- if (FeatureIndex) {
- delete[] FeatureIndex;
- }
- }
+ ~TLangSys() { delete[] FeatureIndex; }
private:
TLangSys(const TLangSys&);
@@ -73,11 +69,7 @@ class CFX_CTTGSUBTable {
TT_uint16_t LangSysCount;
struct TLangSysRecord* LangSysRecord;
TScript() : DefaultLangSys(0), LangSysCount(0), LangSysRecord(NULL) {}
- ~TScript() {
- if (LangSysRecord) {
- delete[] LangSysRecord;
- }
- }
+ ~TScript() { delete[] LangSysRecord; }
private:
TScript(const TScript&);
@@ -96,11 +88,7 @@ class CFX_CTTGSUBTable {
TT_uint16_t ScriptCount;
struct TScriptRecord* ScriptRecord;
TScriptList() : ScriptCount(0), ScriptRecord(NULL) {}
- ~TScriptList() {
- if (ScriptRecord) {
- delete[] ScriptRecord;
- }
- }
+ ~TScriptList() { delete[] ScriptRecord; }
private:
TScriptList(const TScriptList&);
@@ -111,11 +99,7 @@ class CFX_CTTGSUBTable {
int LookupCount;
TT_uint16_t* LookupListIndex;
TFeature() : FeatureParams(0), LookupCount(0), LookupListIndex(NULL) {}
- ~TFeature() {
- if (LookupListIndex) {
- delete[] LookupListIndex;
- }
- }
+ ~TFeature() { delete[] LookupListIndex; }
private:
TFeature(const TFeature&);
@@ -134,11 +118,7 @@ class CFX_CTTGSUBTable {
int FeatureCount;
struct TFeatureRecord* FeatureRecord;
TFeatureList() : FeatureCount(0), FeatureRecord(NULL) {}
- ~TFeatureList() {
- if (FeatureRecord) {
- delete[] FeatureRecord;
- }
- }
+ ~TFeatureList() { delete[] FeatureRecord; }
private:
TFeatureList(const TFeatureList&);
@@ -166,11 +146,7 @@ class CFX_CTTGSUBTable {
TT_uint16_t GlyphCount;
TT_uint16_t* GlyphArray;
TCoverageFormat1() : GlyphCount(0), GlyphArray(NULL) { CoverageFormat = 1; }
- ~TCoverageFormat1() override {
- if (GlyphArray) {
- delete[] GlyphArray;
- }
- }
+ ~TCoverageFormat1() override { delete[] GlyphArray; }
private:
TCoverageFormat1(const TCoverageFormat1&);
@@ -194,11 +170,7 @@ class CFX_CTTGSUBTable {
TCoverageFormat2() : RangeCount(0), RangeRecord(NULL) {
CoverageFormat = 2;
}
- ~TCoverageFormat2() override {
- if (RangeRecord) {
- delete[] RangeRecord;
- }
- }
+ ~TCoverageFormat2() override { delete[] RangeRecord; }
private:
TCoverageFormat2(const TCoverageFormat2&);
@@ -220,11 +192,7 @@ class CFX_CTTGSUBTable {
TClassDefFormat1() : StartGlyph(0), GlyphCount(0), ClassValueArray(NULL) {
ClassFormat = 1;
}
- ~TClassDefFormat1() override {
- if (ClassValueArray) {
- delete[] ClassValueArray;
- }
- }
+ ~TClassDefFormat1() override { delete[] ClassValueArray; }
private:
TClassDefFormat1(const TClassDefFormat1&);
@@ -246,11 +214,7 @@ class CFX_CTTGSUBTable {
TClassDefFormat2() : ClassRangeCount(0), ClassRangeRecord(NULL) {
ClassFormat = 2;
}
- ~TClassDefFormat2() override {
- if (ClassRangeRecord) {
- delete[] ClassRangeRecord;
- }
- }
+ ~TClassDefFormat2() override { delete[] ClassRangeRecord; }
private:
TClassDefFormat2(const TClassDefFormat2&);
@@ -325,11 +289,7 @@ class CFX_CTTGSUBTable {
int LookupCount;
struct TLookup* Lookup;
TLookupList() : LookupCount(0), Lookup(NULL) {}
- ~TLookupList() {
- if (Lookup) {
- delete[] Lookup;
- }
- }
+ ~TLookupList() { delete[] Lookup; }
private:
TLookupList(const TLookupList&);
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index 0421aba2d5..f6f03336a0 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -95,12 +95,10 @@ CPDF_TextObject::CPDF_TextObject()
}
CPDF_TextObject::~CPDF_TextObject() {
- if (m_nChars > 1 && m_pCharCodes) {
+ if (m_nChars > 1) {
FX_Free(m_pCharCodes);
}
- if (m_pCharPos) {
- FX_Free(m_pCharPos);
- }
+ FX_Free(m_pCharPos);
}
void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const {
@@ -186,14 +184,12 @@ void CPDF_TextObject::GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const {
void CPDF_TextObject::CopyData(const CPDF_PageObject* pSrc) {
const CPDF_TextObject* pSrcObj = (const CPDF_TextObject*)pSrc;
- if (m_nChars > 1 && m_pCharCodes) {
+ if (m_nChars > 1) {
FX_Free(m_pCharCodes);
m_pCharCodes = nullptr;
}
- if (m_pCharPos) {
- FX_Free(m_pCharPos);
- m_pCharPos = nullptr;
- }
+ FX_Free(m_pCharPos);
+ m_pCharPos = nullptr;
m_nChars = pSrcObj->m_nChars;
if (m_nChars > 1) {
m_pCharCodes = FX_Alloc(FX_DWORD, m_nChars);
@@ -220,14 +216,12 @@ void CPDF_TextObject::GetTextMatrix(CFX_AffineMatrix* pMatrix) const {
void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs,
FX_FLOAT* pKerning,
int nsegs) {
- if (m_nChars > 1 && m_pCharCodes) {
+ if (m_nChars > 1) {
FX_Free(m_pCharCodes);
m_pCharCodes = nullptr;
}
- if (m_pCharPos) {
- FX_Free(m_pCharPos);
- m_pCharPos = nullptr;
- }
+ FX_Free(m_pCharPos);
+ m_pCharPos = nullptr;
CPDF_Font* pFont = m_TextState.GetFont();
m_nChars = 0;
for (int i = 0; i < nsegs; ++i) {
@@ -262,10 +256,10 @@ void CPDF_TextObject::SetText(const CFX_ByteString& str) {
}
void CPDF_TextObject::SetEmpty() {
- if (m_nChars > 1 && m_pCharCodes) {
+ if (m_nChars > 1) {
FX_Free(m_pCharCodes);
}
- if (m_nChars > 1 && m_pCharPos) {
+ if (m_nChars > 1) {
FX_Free(m_pCharPos);
}
m_nChars = 0;
@@ -285,14 +279,12 @@ void CPDF_TextObject::SetText(CFX_ByteString* pStrs,
void CPDF_TextObject::SetText(int nChars,
FX_DWORD* pCharCodes,
FX_FLOAT* pKernings) {
- if (m_nChars > 1 && m_pCharCodes) {
+ if (m_nChars > 1) {
FX_Free(m_pCharCodes);
m_pCharCodes = nullptr;
}
- if (m_pCharPos) {
- FX_Free(m_pCharPos);
- m_pCharPos = nullptr;
- }
+ FX_Free(m_pCharPos);
+ m_pCharPos = nullptr;
int nKernings = 0;
int i;
for (i = 0; i < nChars - 1; ++i) {
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
index cc6c9e9d56..a3fef3df82 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
@@ -671,12 +671,8 @@ class CPDF_ICCBasedCS : public CPDF_ColorSpace {
};
CPDF_ICCBasedCS::~CPDF_ICCBasedCS() {
- if (m_pCache) {
- FX_Free(m_pCache);
- }
- if (m_pRanges) {
- FX_Free(m_pRanges);
- }
+ FX_Free(m_pCache);
+ FX_Free(m_pRanges);
if (m_pAlterCS && m_bOwn) {
m_pAlterCS->ReleaseCS();
}
@@ -882,9 +878,7 @@ class CPDF_IndexedCS : public CPDF_ColorSpace {
FX_FLOAT* m_pCompMinMax;
};
CPDF_IndexedCS::~CPDF_IndexedCS() {
- if (m_pCompMinMax) {
- FX_Free(m_pCompMinMax);
- }
+ FX_Free(m_pCompMinMax);
CPDF_ColorSpace* pCS = m_pCountedBaseCS ? m_pCountedBaseCS->get() : NULL;
if (pCS && m_pDocument) {
m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray());
@@ -1460,9 +1454,7 @@ void CPDF_Color::SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comps, int ncomps) {
return;
}
if (m_pCS == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) {
- if (m_pBuffer) {
- FX_Free(m_pBuffer);
- }
+ FX_Free(m_pBuffer);
m_pCS = CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN);
m_pBuffer = m_pCS->CreateBuf();
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
index 1ee062ee7c..8c909a9e68 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
@@ -487,12 +487,8 @@ CPDF_SampledFunc::CPDF_SampledFunc() {
}
CPDF_SampledFunc::~CPDF_SampledFunc() {
delete m_pSampleStream;
- if (m_pEncodeInfo) {
- FX_Free(m_pEncodeInfo);
- }
- if (m_pDecodeInfo) {
- FX_Free(m_pDecodeInfo);
- }
+ FX_Free(m_pEncodeInfo);
+ FX_Free(m_pDecodeInfo);
}
FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) {
if (pObj->GetType() != PDFOBJ_STREAM) {
@@ -678,12 +674,8 @@ CPDF_ExpIntFunc::CPDF_ExpIntFunc() {
m_pEndValues = NULL;
}
CPDF_ExpIntFunc::~CPDF_ExpIntFunc() {
- if (m_pBeginValues) {
FX_Free(m_pBeginValues);
- }
- if (m_pEndValues) {
FX_Free(m_pEndValues);
- }
}
FX_BOOL CPDF_ExpIntFunc::v_Init(CPDF_Object* pObj) {
CPDF_Dictionary* pDict = pObj->GetDict();
@@ -747,15 +739,9 @@ CPDF_StitchFunc::CPDF_StitchFunc() {
CPDF_StitchFunc::~CPDF_StitchFunc() {
for (int i = 0; i < m_nSubs; i++)
delete m_pSubFunctions[i];
- if (m_pSubFunctions) {
- FX_Free(m_pSubFunctions);
- }
- if (m_pBounds) {
- FX_Free(m_pBounds);
- }
- if (m_pEncode) {
- FX_Free(m_pEncode);
- }
+ FX_Free(m_pSubFunctions);
+ FX_Free(m_pBounds);
+ FX_Free(m_pEncode);
}
FX_BOOL CPDF_StitchFunc::v_Init(CPDF_Object* pObj) {
CPDF_Dictionary* pDict = pObj->GetDict();
@@ -859,14 +845,8 @@ CPDF_Function::CPDF_Function() {
m_pRanges = NULL;
}
CPDF_Function::~CPDF_Function() {
- if (m_pDomains) {
- FX_Free(m_pDomains);
- m_pDomains = NULL;
- }
- if (m_pRanges) {
- FX_Free(m_pRanges);
- m_pRanges = NULL;
- }
+ FX_Free(m_pDomains);
+ FX_Free(m_pRanges);
}
FX_BOOL CPDF_Function::Init(CPDF_Object* pObj) {
CPDF_Dictionary* pDict;
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 e010a28b02..f11a2bb8d1 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
@@ -31,14 +31,10 @@ CPDF_ClipPathData::CPDF_ClipPathData() {
CPDF_ClipPathData::~CPDF_ClipPathData() {
int i;
delete[] m_pPathList;
- if (m_pTypeList) {
- FX_Free(m_pTypeList);
- }
+ FX_Free(m_pTypeList);
for (i = m_TextCount - 1; i > -1; i--)
delete m_pTextList[i];
- if (m_pTextList) {
- FX_Free(m_pTextList);
- }
+ FX_Free(m_pTextList);
}
CPDF_ClipPathData::CPDF_ClipPathData(const CPDF_ClipPathData& src) {
m_pPathList = NULL;
@@ -148,9 +144,7 @@ void CPDF_ClipPath::AppendPath(CPDF_Path path, int type, FX_BOOL bAutoMerge) {
delete[] pData->m_pPathList;
uint8_t* pNewType = FX_Alloc(uint8_t, pData->m_PathCount + 8);
FXSYS_memcpy(pNewType, pData->m_pTypeList, pData->m_PathCount);
- if (pData->m_pTypeList) {
- FX_Free(pData->m_pTypeList);
- }
+ FX_Free(pData->m_pTypeList);
pData->m_pPathList = pNewPath;
pData->m_pTypeList = pNewType;
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 47ba46a0f3..059dd4c2a6 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -83,9 +83,7 @@ CPDF_StreamContentParser::~CPDF_StreamContentParser() {
for (int i = 0; i < m_StateStack.GetSize(); ++i) {
delete (CPDF_AllStates*)m_StateStack[i];
}
- if (m_pPathPoints) {
- FX_Free(m_pPathPoints);
- }
+ FX_Free(m_pPathPoints);
if (m_pLastImageDict) {
m_pLastImageDict->Release();
}
@@ -1087,9 +1085,7 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Fill() {
} else {
m_pCurStates->m_ColorState.SetFillColor(NULL, values, nvalues);
}
- if (values) {
- FX_Free(values);
- }
+ FX_Free(values);
}
void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() {
if (m_Options.m_bTextOnly) {
@@ -1119,9 +1115,7 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() {
} else {
m_pCurStates->m_ColorState.SetStrokeColor(NULL, values, nvalues);
}
- if (values) {
- FX_Free(values);
- }
+ FX_Free(values);
}
CFX_FloatRect _GetShadingBBox(CPDF_Stream* pStream,
int type,
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 78169614bd..48e9b98d3a 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -439,9 +439,7 @@ CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc,
pDict->RemoveAt(FX_BSTRC("DecodeParms"));
}
} else {
- if (pData) {
- FX_Free(pData);
- }
+ FX_Free(pData);
FX_DWORD dwSavePos = m_Pos;
m_Pos += dwStreamSize;
while (1) {
@@ -960,9 +958,8 @@ void CPDF_ContentParser::Clear() {
delete m_pStreamArray[i];
FX_Free(m_pStreamArray);
}
- if (m_pData && m_pSingleStream == NULL) {
- FX_Free((void*)m_pData);
- }
+ if (!m_pSingleStream)
+ FX_Free(m_pData);
m_pParser = NULL;
m_pStreamArray = NULL;
m_pSingleStream = NULL;
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp
index 55e648a054..125b7e0bf5 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp
@@ -1040,7 +1040,5 @@ CPDF_StandardCryptoHandler::CPDF_StandardCryptoHandler() {
m_KeyLen = 0;
}
CPDF_StandardCryptoHandler::~CPDF_StandardCryptoHandler() {
- if (m_pAESContext) {
- FX_Free(m_pAESContext);
- }
+ FX_Free(m_pAESContext);
}
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
index d4deb1df3b..eed62013f5 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
@@ -828,7 +828,7 @@ CPDF_Stream::CPDF_Stream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict)
m_pCryptoHandler = NULL;
}
CPDF_Stream::~CPDF_Stream() {
- if (m_GenNum == (FX_DWORD)-1 && m_pDataBuf != NULL) {
+ if (m_GenNum == (FX_DWORD)-1) {
FX_Free(m_pDataBuf);
}
if (m_pDict) {
@@ -843,9 +843,7 @@ void CPDF_Stream::InitStream(CPDF_Dictionary* pDict) {
m_pDict = pDict;
}
if (m_GenNum == (FX_DWORD)-1) {
- if (m_pDataBuf) {
- FX_Free(m_pDataBuf);
- }
+ FX_Free(m_pDataBuf);
}
m_GenNum = 0;
m_pFile = NULL;
@@ -871,9 +869,7 @@ void CPDF_Stream::SetData(const uint8_t* pData,
FX_BOOL bCompressed,
FX_BOOL bKeepBuf) {
if (m_GenNum == (FX_DWORD)-1) {
- if (m_pDataBuf) {
- FX_Free(m_pDataBuf);
- }
+ FX_Free(m_pDataBuf);
} else {
m_GenNum = (FX_DWORD)-1;
m_pCryptoHandler = NULL;
@@ -1101,12 +1097,10 @@ void CPDF_StreamAcc::LoadAllData(const CPDF_Stream* pStream,
m_bNewBuf = m_pData != pStream->m_pDataBuf;
}
CPDF_StreamAcc::~CPDF_StreamAcc() {
- if (m_bNewBuf && m_pData) {
+ if (m_bNewBuf) {
FX_Free(m_pData);
}
- if (m_pSrcData) {
- FX_Free(m_pSrcData);
- }
+ FX_Free(m_pSrcData);
}
const uint8_t* CPDF_StreamAcc::GetData() const {
if (m_bNewBuf) {
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index e5d0b6a17b..e78ee4596d 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -1735,9 +1735,7 @@ CPDF_SyntaxParser::CPDF_SyntaxParser() {
m_bFileStream = FALSE;
}
CPDF_SyntaxParser::~CPDF_SyntaxParser() {
- if (m_pFileBuf) {
- FX_Free(m_pFileBuf);
- }
+ FX_Free(m_pFileBuf);
}
FX_BOOL CPDF_SyntaxParser::GetCharAt(FX_FILESIZE pos, uint8_t& ch) {
FX_FILESIZE save_pos = m_Pos;
@@ -2598,10 +2596,7 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict,
}
void CPDF_SyntaxParser::InitParser(IFX_FileRead* pFileAccess,
FX_DWORD HeaderOffset) {
- if (m_pFileBuf) {
- FX_Free(m_pFileBuf);
- m_pFileBuf = NULL;
- }
+ FX_Free(m_pFileBuf);
m_pFileBuf = FX_Alloc(uint8_t, m_BufSize);
m_HeaderOffset = HeaderOffset;
m_FileLen = pFileAccess->GetSize();
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
index e066957e62..8a614810df 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -182,17 +182,11 @@ CPDF_DIBSource::CPDF_DIBSource() {
}
CPDF_DIBSource::~CPDF_DIBSource() {
delete m_pStreamAcc;
- if (m_pMaskedLine) {
- FX_Free(m_pMaskedLine);
- }
- if (m_pLineBuf) {
- FX_Free(m_pLineBuf);
- }
+ FX_Free(m_pMaskedLine);
+ FX_Free(m_pLineBuf);
m_pCachedBitmap.reset();
delete m_pDecoder;
- if (m_pCompData) {
- FX_Free(m_pCompData);
- }
+ FX_Free(m_pCompData);
CPDF_ColorSpace* pCS = m_pColorSpace;
if (pCS && m_pDocument) {
m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray());
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
index 7d6921f544..d36125e1b8 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -531,9 +531,7 @@ CPDF_CharPosList::CPDF_CharPosList() {
m_pCharPos = NULL;
}
CPDF_CharPosList::~CPDF_CharPosList() {
- if (m_pCharPos) {
- FX_Free(m_pCharPos);
- }
+ FX_Free(m_pCharPos);
}
void CPDF_CharPosList::Load(int nChars,
FX_DWORD* pCharCodes,