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

Side by Side Diff: core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp

Issue 1192743004: Cleanup: Do not check pointers before deleting them. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 6 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
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 "../../../include/fpdfapi/fpdf_render.h" 7 #include "../../../include/fpdfapi/fpdf_render.h"
8 #include "../../../include/fpdfapi/fpdf_pageobj.h" 8 #include "../../../include/fpdfapi/fpdf_pageobj.h"
9 #include "../../../include/fxge/fx_ge.h" 9 #include "../../../include/fxge/fx_ge.h"
10 #include "../fpdf_page/pageint.h" 10 #include "../fpdf_page/pageint.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 , m_pRenderStatus(NULL) 181 , m_pRenderStatus(NULL)
182 , m_pDocument(pDoc) 182 , m_pDocument(pDoc)
183 , m_pStream(pStream) 183 , m_pStream(pStream)
184 , m_pCachedBitmap(NULL) 184 , m_pCachedBitmap(NULL)
185 , m_pCachedMask(NULL) 185 , m_pCachedMask(NULL)
186 , m_dwCacheSize(0) 186 , m_dwCacheSize(0)
187 { 187 {
188 } 188 }
189 CPDF_ImageCache::~CPDF_ImageCache() 189 CPDF_ImageCache::~CPDF_ImageCache()
190 { 190 {
191 if (m_pCachedBitmap) { 191 delete m_pCachedBitmap;
192 delete m_pCachedBitmap; 192 m_pCachedBitmap = NULL;
193 m_pCachedBitmap = NULL; 193 delete m_pCachedMask;
194 } 194 m_pCachedMask = NULL;
195 if (m_pCachedMask) {
196 delete m_pCachedMask;
197 m_pCachedMask = NULL;
198 }
199 } 195 }
200 void CPDF_ImageCache::Reset(const CFX_DIBitmap* pBitmap) 196 void CPDF_ImageCache::Reset(const CFX_DIBitmap* pBitmap)
201 { 197 {
202 if (m_pCachedBitmap) { 198 delete m_pCachedBitmap;
203 delete m_pCachedBitmap;
204 }
205 m_pCachedBitmap = NULL; 199 m_pCachedBitmap = NULL;
206 if (pBitmap) { 200 if (pBitmap) {
207 m_pCachedBitmap = pBitmap->Clone(); 201 m_pCachedBitmap = pBitmap->Clone();
208 } 202 }
209 CalcSize(); 203 CalcSize();
210 } 204 }
211 void CPDF_PageRenderCache::ClearImageData() 205 void CPDF_PageRenderCache::ClearImageData()
212 { 206 {
213 FX_POSITION pos = m_ImageCaches.GetStartPosition(); 207 FX_POSITION pos = m_ImageCaches.GetStartPosition();
214 while (pos) { 208 while (pos) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 344 }
351 void CPDF_Document::ClearRenderFont() 345 void CPDF_Document::ClearRenderFont()
352 { 346 {
353 if (m_pDocRender) { 347 if (m_pDocRender) {
354 CFX_FontCache* pCache = m_pDocRender->GetFontCache(); 348 CFX_FontCache* pCache = m_pDocRender->GetFontCache();
355 if (pCache) { 349 if (pCache) {
356 pCache->FreeCache(FALSE); 350 pCache->FreeCache(FALSE);
357 } 351 }
358 } 352 }
359 } 353 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698