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

Side by Side Diff: core/src/fxcodec/codec/fx_codec.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 unified diff | Download patch
« no previous file with comments | « core/src/fxcodec/codec/codec_int.h ('k') | core/src/fxcodec/codec/fx_codec_fax.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 "../../../include/fxcodec/fx_codec.h" 7 #include "../../../include/fxcodec/fx_codec.h"
8 #include "codec_int.h" 8 #include "codec_int.h"
9 CCodec_ModuleMgr::CCodec_ModuleMgr() 9 CCodec_ModuleMgr::CCodec_ModuleMgr()
10 : m_pBasicModule(new CCodec_BasicModule), 10 : m_pBasicModule(new CCodec_BasicModule),
11 m_pFaxModule(new CCodec_FaxModule), 11 m_pFaxModule(new CCodec_FaxModule),
12 m_pJpegModule(new CCodec_JpegModule), 12 m_pJpegModule(new CCodec_JpegModule),
13 m_pJpxModule(new CCodec_JpxModule), 13 m_pJpxModule(new CCodec_JpxModule),
14 m_pJbig2Module(new CCodec_Jbig2Module), 14 m_pJbig2Module(new CCodec_Jbig2Module),
15 m_pIccModule(new CCodec_IccModule), 15 m_pIccModule(new CCodec_IccModule),
16 m_pFlateModule(new CCodec_FlateModule) {} 16 m_pFlateModule(new CCodec_FlateModule) {}
17 CCodec_ScanlineDecoder::CCodec_ScanlineDecoder() { 17 CCodec_ScanlineDecoder::CCodec_ScanlineDecoder() {
18 m_NextLine = -1; 18 m_NextLine = -1;
19 m_pDataCache = NULL; 19 m_pDataCache = NULL;
20 m_pLastScanline = NULL; 20 m_pLastScanline = NULL;
21 } 21 }
22 CCodec_ScanlineDecoder::~CCodec_ScanlineDecoder() { 22 CCodec_ScanlineDecoder::~CCodec_ScanlineDecoder() {
23 if (m_pDataCache) { 23 FX_Free(m_pDataCache);
24 FX_Free(m_pDataCache);
25 }
26 } 24 }
27 uint8_t* CCodec_ScanlineDecoder::GetScanline(int line) { 25 uint8_t* CCodec_ScanlineDecoder::GetScanline(int line) {
28 if (m_pDataCache && line < m_pDataCache->m_nCachedLines) { 26 if (m_pDataCache && line < m_pDataCache->m_nCachedLines) {
29 return &m_pDataCache->m_Data + line * m_Pitch; 27 return &m_pDataCache->m_Data + line * m_Pitch;
30 } 28 }
31 if (m_NextLine == line + 1) { 29 if (m_NextLine == line + 1) {
32 return m_pLastScanline; 30 return m_pLastScanline;
33 } 31 }
34 if (m_NextLine < 0 || m_NextLine > line) { 32 if (m_NextLine < 0 || m_NextLine > line) {
35 if (!v_Rewind()) { 33 if (!v_Rewind()) {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 }; 245 };
248 CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder() 246 CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder()
249 : m_pScanline(NULL), 247 : m_pScanline(NULL),
250 m_pSrcBuf(NULL), 248 m_pSrcBuf(NULL),
251 m_SrcSize(0), 249 m_SrcSize(0),
252 m_dwLineBytes(0), 250 m_dwLineBytes(0),
253 m_SrcOffset(0), 251 m_SrcOffset(0),
254 m_bEOD(FALSE), 252 m_bEOD(FALSE),
255 m_Operator(0) {} 253 m_Operator(0) {}
256 CCodec_RLScanlineDecoder::~CCodec_RLScanlineDecoder() { 254 CCodec_RLScanlineDecoder::~CCodec_RLScanlineDecoder() {
257 if (m_pScanline) { 255 FX_Free(m_pScanline);
258 FX_Free(m_pScanline);
259 }
260 } 256 }
261 FX_BOOL CCodec_RLScanlineDecoder::CheckDestSize() { 257 FX_BOOL CCodec_RLScanlineDecoder::CheckDestSize() {
262 FX_DWORD i = 0; 258 FX_DWORD i = 0;
263 FX_DWORD old_size = 0; 259 FX_DWORD old_size = 0;
264 FX_DWORD dest_size = 0; 260 FX_DWORD dest_size = 0;
265 while (i < m_SrcSize) { 261 while (i < m_SrcSize) {
266 if (m_pSrcBuf[i] < 128) { 262 if (m_pSrcBuf[i] < 128) {
267 old_size = dest_size; 263 old_size = dest_size;
268 dest_size += m_pSrcBuf[i] + 1; 264 dest_size += m_pSrcBuf[i] + 1;
269 if (dest_size < old_size) { 265 if (dest_size < old_size) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 int nComps, 398 int nComps,
403 int bpc) { 399 int bpc) {
404 CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder; 400 CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder;
405 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, 401 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps,
406 bpc)) { 402 bpc)) {
407 delete pRLScanlineDecoder; 403 delete pRLScanlineDecoder;
408 return NULL; 404 return NULL;
409 } 405 }
410 return pRLScanlineDecoder; 406 return pRLScanlineDecoder;
411 } 407 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/codec_int.h ('k') | core/src/fxcodec/codec/fx_codec_fax.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698