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

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

Issue 1195363002: Cleanup: Do not check pointers before deleting them, part 2. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: nits Created 5 years, 5 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_module.h" 7 #include "../../../include/fpdfapi/fpdf_module.h"
8 #include "../../../include/fpdfapi/fpdf_pageobj.h" 8 #include "../../../include/fpdfapi/fpdf_pageobj.h"
9 #include "../../../include/fpdfapi/fpdf_render.h" 9 #include "../../../include/fpdfapi/fpdf_render.h"
10 #include "../../../include/fxcodec/fx_codec.h" 10 #include "../../../include/fxcodec/fx_codec.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 m_LoadHandle = NULL; 290 m_LoadHandle = NULL;
291 m_pClone = NULL; 291 m_pClone = NULL;
292 m_bStdCS = FALSE; 292 m_bStdCS = FALSE;
293 m_bPatternColor = FALSE; 293 m_bPatternColor = FALSE;
294 m_BlendType = FXDIB_BLEND_NORMAL; 294 m_BlendType = FXDIB_BLEND_NORMAL;
295 m_pPattern = NULL; 295 m_pPattern = NULL;
296 m_pObj2Device = NULL; 296 m_pObj2Device = NULL;
297 } 297 }
298 CPDF_ImageRenderer::~CPDF_ImageRenderer() 298 CPDF_ImageRenderer::~CPDF_ImageRenderer()
299 { 299 {
300 if (m_pQuickStretcher) { 300 delete m_pQuickStretcher;
301 delete m_pQuickStretcher; 301 delete m_pTransformer;
302 }
303 if (m_pTransformer) {
304 delete m_pTransformer;
305 }
306 if (m_DeviceHandle) { 302 if (m_DeviceHandle) {
307 m_pRenderStatus->m_pDevice->CancelDIBits(m_DeviceHandle); 303 m_pRenderStatus->m_pDevice->CancelDIBits(m_DeviceHandle);
308 } 304 }
309 if (m_LoadHandle) { 305 delete (CPDF_ProgressiveImageLoaderHandle*)m_LoadHandle;
310 delete (CPDF_ProgressiveImageLoaderHandle*)m_LoadHandle; 306 delete m_pClone;
311 }
312 if (m_pClone) {
313 delete m_pClone;
314 }
315 } 307 }
316 FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource() 308 FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource()
317 { 309 {
318 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); 310 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect();
319 FX_RECT image_rect = image_rect_f.GetOutterRect(); 311 FX_RECT image_rect = image_rect_f.GetOutterRect();
320 int dest_width = image_rect.Width(); 312 int dest_width = image_rect.Width();
321 int dest_height = image_rect.Height(); 313 int dest_height = image_rect.Height();
322 if (m_ImageMatrix.a < 0) { 314 if (m_ImageMatrix.a < 0) {
323 dest_width = -dest_width; 315 dest_width = -dest_width;
324 } 316 }
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 return FALSE; 798 return FALSE;
807 } 799 }
808 CPDF_QuickStretcher::CPDF_QuickStretcher() 800 CPDF_QuickStretcher::CPDF_QuickStretcher()
809 { 801 {
810 m_pBitmap = NULL; 802 m_pBitmap = NULL;
811 m_pDecoder = NULL; 803 m_pDecoder = NULL;
812 m_pCS = NULL; 804 m_pCS = NULL;
813 } 805 }
814 CPDF_QuickStretcher::~CPDF_QuickStretcher() 806 CPDF_QuickStretcher::~CPDF_QuickStretcher()
815 { 807 {
816 if (m_pBitmap) { 808 delete m_pBitmap;
817 delete m_pBitmap;
818 }
819 if (m_pCS) { 809 if (m_pCS) {
820 m_pCS->ReleaseCS(); 810 m_pCS->ReleaseCS();
821 } 811 }
822 if (m_pDecoder) { 812 delete m_pDecoder;
823 delete m_pDecoder;
824 }
825 } 813 }
826 ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(const uint8_t* src_buf, FX_DW ORD src_size, int width, int height, 814 ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(const uint8_t* src_buf, FX_DW ORD src_size, int width, int height,
827 int nComps, int bpc, const CPDF_Dictionary* pParams); 815 int nComps, int bpc, const CPDF_Dictionary* pParams);
828 FX_BOOL CPDF_QuickStretcher::Start(CPDF_ImageObject* pImageObj, CFX_AffineMatrix * pImage2Device, const FX_RECT* pClipBox) 816 FX_BOOL CPDF_QuickStretcher::Start(CPDF_ImageObject* pImageObj, CFX_AffineMatrix * pImage2Device, const FX_RECT* pClipBox)
829 { 817 {
830 if (FXSYS_fabs(pImage2Device->a) < FXSYS_fabs(pImage2Device->b) * 10 && FXSY S_fabs(pImage2Device->d) < FXSYS_fabs(pImage2Device->c) * 10) { 818 if (FXSYS_fabs(pImage2Device->a) < FXSYS_fabs(pImage2Device->b) * 10 && FXSY S_fabs(pImage2Device->d) < FXSYS_fabs(pImage2Device->c) * 10) {
831 return FALSE; 819 return FALSE;
832 } 820 }
833 CFX_FloatRect image_rect_f = pImage2Device->GetUnitRect(); 821 CFX_FloatRect image_rect_f = pImage2Device->GetUnitRect();
834 FX_RECT image_rect = image_rect_f.GetOutterRect(); 822 FX_RECT image_rect = image_rect_f.GetOutterRect();
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 } 1066 }
1079 } 1067 }
1080 } else if (pFunc) { 1068 } else if (pFunc) {
1081 int size = dest_pitch * height; 1069 int size = dest_pitch * height;
1082 for (int i = 0; i < size; i ++) { 1070 for (int i = 0; i < size; i ++) {
1083 dest_buf[i] = pTransfer[src_buf[i]]; 1071 dest_buf[i] = pTransfer[src_buf[i]];
1084 } 1072 }
1085 } else { 1073 } else {
1086 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); 1074 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height);
1087 } 1075 }
1088 if (pFunc) { 1076 delete pFunc;
1089 delete pFunc;
1090 }
1091 FX_Free(pTransfer); 1077 FX_Free(pTransfer);
1092 return pMask; 1078 return pMask;
1093 } 1079 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_render/fpdf_render.cpp ('k') | core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698