Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1617)

Unified Diff: core/src/fpdfapi/fpdf_page/fpdf_page.cpp

Issue 1297713003: Don't bother checking pointers before delete[] and FX_Free(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fpdfapi/fpdf_font/ttgsubtable.h ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_page/fpdf_page.cpp
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index 0421aba2d593f69ca78bf68ceb5ab0e7afe629c9..f6f03336a0a4f02bfd3628222e91b100edddd3c7 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) {
« no previous file with comments | « core/src/fpdfapi/fpdf_font/ttgsubtable.h ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698