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

Side by Side Diff: xfa/fee/fde_txtedtpage.cpp

Issue 1925363002: Do not check pointers before deleting them. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « xfa/fee/fde_txtedtengine.cpp ('k') | xfa/fgas/font/fgas_stdfontmgr.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fee/fde_txtedtpage.h" 7 #include "xfa/fee/fde_txtedtpage.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 m_nCharCount(0), 132 m_nCharCount(0),
133 m_nPageIndex(nPageIndex), 133 m_nPageIndex(nPageIndex),
134 m_bLoaded(FALSE), 134 m_bLoaded(FALSE),
135 m_pCharWidth(nullptr) { 135 m_pCharWidth(nullptr) {
136 FXSYS_memset(&m_rtPage, 0, sizeof(CFX_RectF)); 136 FXSYS_memset(&m_rtPage, 0, sizeof(CFX_RectF));
137 FXSYS_memset(&m_rtPageMargin, 0, sizeof(CFX_RectF)); 137 FXSYS_memset(&m_rtPageMargin, 0, sizeof(CFX_RectF));
138 FXSYS_memset(&m_rtPageContents, 0, sizeof(CFX_RectF)); 138 FXSYS_memset(&m_rtPageContents, 0, sizeof(CFX_RectF));
139 FXSYS_memset(&m_rtPageCanvas, 0, sizeof(CFX_RectF)); 139 FXSYS_memset(&m_rtPageCanvas, 0, sizeof(CFX_RectF));
140 m_pEditEngine = (CFDE_TxtEdtEngine*)pEngine; 140 m_pEditEngine = (CFDE_TxtEdtEngine*)pEngine;
141 } 141 }
142
142 CFDE_TxtEdtPage::~CFDE_TxtEdtPage() { 143 CFDE_TxtEdtPage::~CFDE_TxtEdtPage() {
143 m_PieceMassArr.RemoveAll(TRUE); 144 m_PieceMassArr.RemoveAll(TRUE);
144 if (m_pTextSet) { 145 delete m_pTextSet;
145 delete m_pTextSet; 146 delete[] m_pCharWidth;
146 m_pTextSet = NULL; 147 if (m_pIter)
147 }
148 if (m_pCharWidth) {
149 delete[] m_pCharWidth;
150 m_pCharWidth = NULL;
151 }
152 if (m_pIter != NULL) {
153 m_pIter->Release(); 148 m_pIter->Release();
154 m_pIter = NULL;
155 }
156 } 149 }
150
157 void CFDE_TxtEdtPage::Release() { 151 void CFDE_TxtEdtPage::Release() {
158 delete this; 152 delete this;
159 } 153 }
160 IFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const { 154 IFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const {
161 return (IFDE_TxtEdtEngine*)m_pEditEngine; 155 return (IFDE_TxtEdtEngine*)m_pEditEngine;
162 } 156 }
163 FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() { 157 FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() {
164 return FDE_VISUALOBJ_Text; 158 return FDE_VISUALOBJ_Text;
165 } 159 }
166 FX_BOOL CFDE_TxtEdtPage::GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) { 160 FX_BOOL CFDE_TxtEdtPage::GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) {
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 m_rtPageContents.height -= pParams->fLineSpace - pParams->fFontSize; 542 m_rtPageContents.height -= pParams->fLineSpace - pParams->fFontSize;
549 int32_t nCount = m_PieceMassArr.GetSize(); 543 int32_t nCount = m_PieceMassArr.GetSize();
550 FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(nCount - 1); 544 FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(nCount - 1);
551 pPiece->rtPiece.height = pParams->fFontSize; 545 pPiece->rtPiece.height = pParams->fFontSize;
552 } 546 }
553 pIter->Release(); 547 pIter->Release();
554 m_nRefCount = 1; 548 m_nRefCount = 1;
555 m_bLoaded = TRUE; 549 m_bLoaded = TRUE;
556 return 0; 550 return 0;
557 } 551 }
552
558 void CFDE_TxtEdtPage::UnloadPage(const CFX_RectF* pClipBox) { 553 void CFDE_TxtEdtPage::UnloadPage(const CFX_RectF* pClipBox) {
559 ASSERT(m_nRefCount > 0); 554 ASSERT(m_nRefCount > 0);
560 m_nRefCount--; 555 m_nRefCount--;
561 if (m_nRefCount == 0) { 556 if (m_nRefCount != 0)
562 m_PieceMassArr.RemoveAll(); 557 return;
563 if (m_pTextSet) { 558
564 delete m_pTextSet; 559 m_PieceMassArr.RemoveAll();
565 m_pTextSet = NULL; 560 delete m_pTextSet;
566 } 561 m_pTextSet = nullptr;
567 if (m_pCharWidth) { 562 delete[] m_pCharWidth;
568 delete[] m_pCharWidth; 563 m_pCharWidth = nullptr;
569 m_pCharWidth = NULL; 564 if (m_pBgnParag)
570 } 565 m_pBgnParag->UnloadParag();
571 if (m_pBgnParag) { 566 if (m_pEndParag)
572 m_pBgnParag->UnloadParag(); 567 m_pEndParag->UnloadParag();
573 } 568 if (m_pIter) {
574 if (m_pEndParag) { 569 m_pIter->Release();
575 m_pEndParag->UnloadParag(); 570 m_pIter = nullptr;
576 }
577 if (m_pIter) {
578 m_pIter->Release();
579 m_pIter = NULL;
580 }
581 m_pBgnParag = NULL;
582 m_pEndParag = NULL;
583 } 571 }
572 m_pBgnParag = nullptr;
573 m_pEndParag = nullptr;
584 } 574 }
585 575
586 const CFX_RectF& CFDE_TxtEdtPage::GetContentsBox() { 576 const CFX_RectF& CFDE_TxtEdtPage::GetContentsBox() {
587 return m_rtPageContents; 577 return m_rtPageContents;
588 } 578 }
589 FX_POSITION CFDE_TxtEdtPage::GetFirstPosition(FDE_HVISUALOBJ hCanvas) { 579 FX_POSITION CFDE_TxtEdtPage::GetFirstPosition(FDE_HVISUALOBJ hCanvas) {
590 if (m_PieceMassArr.GetSize() < 1) { 580 if (m_PieceMassArr.GetSize() < 1) {
591 return NULL; 581 return NULL;
592 } 582 }
593 return (FX_POSITION)1; 583 return (FX_POSITION)1;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 ptF.x = rtF.left; 627 ptF.x = rtF.left;
638 } else if (ptF.x >= rtF.right()) { 628 } else if (ptF.x >= rtF.right()) {
639 ptF.x = rtF.right() - fTolerance; 629 ptF.x = rtF.right() - fTolerance;
640 } 630 }
641 if (ptF.y < rtF.top) { 631 if (ptF.y < rtF.top) {
642 ptF.y = rtF.top; 632 ptF.y = rtF.top;
643 } else if (ptF.y >= rtF.bottom()) { 633 } else if (ptF.y >= rtF.bottom()) {
644 ptF.y = rtF.bottom() - fTolerance; 634 ptF.y = rtF.bottom() - fTolerance;
645 } 635 }
646 } 636 }
OLDNEW
« no previous file with comments | « xfa/fee/fde_txtedtengine.cpp ('k') | xfa/fgas/font/fgas_stdfontmgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698