summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-08-14 15:45:39 -0700
committerLei Zhang <thestig@chromium.org>2015-08-14 15:45:39 -0700
commitcb62e7657b3a9a04142028a4e6614029a08e894b (patch)
treee7fa5f4c7d7f12bff9315475a89872fb044c36b1 /core/src/fpdfapi/fpdf_page/fpdf_page.cpp
parent0f6b51c0fdd14f5762bf3c7412ac59c825443cc3 (diff)
downloadpdfium-cb62e7657b3a9a04142028a4e6614029a08e894b.tar.xz
Don't bother checking pointers before delete[] and FX_Free().
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1297713003 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_page/fpdf_page.cpp')
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp34
1 files changed, 13 insertions, 21 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) {