diff options
Diffstat (limited to 'core/src/fpdfapi/fpdf_page')
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page.cpp | 34 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp | 16 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp | 34 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp | 12 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 12 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 9 |
6 files changed, 33 insertions, 84 deletions
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; |