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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp

Issue 1192743004: Cleanup: Do not check pointers before deleting them. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase 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 "../../../../third_party/zlib_v128/zlib.h" 7 #include "../../../../third_party/zlib_v128/zlib.h"
8 #include "../../../include/fpdfapi/fpdf_parser.h" 8 #include "../../../include/fpdfapi/fpdf_parser.h"
9 #include "../../../include/fxcodec/fx_codec.h" 9 #include "../../../include/fxcodec/fx_codec.h"
10 #include "../../../include/fpdfapi/fpdf_module.h" 10 #include "../../../include/fpdfapi/fpdf_module.h"
11 #include "filters_int.h" 11 #include "filters_int.h"
12 12
13 CFX_DataFilter::CFX_DataFilter() 13 CFX_DataFilter::CFX_DataFilter()
14 { 14 {
15 m_bEOF = FALSE; 15 m_bEOF = FALSE;
16 m_pDestFilter = NULL; 16 m_pDestFilter = NULL;
17 m_SrcPos = 0; 17 m_SrcPos = 0;
18 } 18 }
19 CFX_DataFilter::~CFX_DataFilter() 19 CFX_DataFilter::~CFX_DataFilter()
20 { 20 {
21 if (m_pDestFilter) { 21 delete m_pDestFilter;
22 delete m_pDestFilter;
23 }
24 } 22 }
25 void CFX_DataFilter::SetDestFilter(CFX_DataFilter* pFilter) 23 void CFX_DataFilter::SetDestFilter(CFX_DataFilter* pFilter)
26 { 24 {
27 if (m_pDestFilter) { 25 if (m_pDestFilter) {
28 m_pDestFilter->SetDestFilter(pFilter); 26 m_pDestFilter->SetDestFilter(pFilter);
29 } else { 27 } else {
30 m_pDestFilter = pFilter; 28 m_pDestFilter = pFilter;
31 } 29 }
32 } 30 }
33 void CFX_DataFilter::FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_Bin aryBuf& dest_buf) 31 void CFX_DataFilter::FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_Bin aryBuf& dest_buf)
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 183 }
186 CPDF_StreamFilter* pStreamFilter = new CPDF_StreamFilter; 184 CPDF_StreamFilter* pStreamFilter = new CPDF_StreamFilter;
187 pStreamFilter->m_pStream = this; 185 pStreamFilter->m_pStream = this;
188 pStreamFilter->m_pFilter = pFirstFilter; 186 pStreamFilter->m_pFilter = pFirstFilter;
189 pStreamFilter->m_pBuffer = NULL; 187 pStreamFilter->m_pBuffer = NULL;
190 pStreamFilter->m_SrcOffset = 0; 188 pStreamFilter->m_SrcOffset = 0;
191 return pStreamFilter; 189 return pStreamFilter;
192 } 190 }
193 CPDF_StreamFilter::~CPDF_StreamFilter() 191 CPDF_StreamFilter::~CPDF_StreamFilter()
194 { 192 {
195 if (m_pFilter) { 193 delete m_pFilter;
196 delete m_pFilter; 194 delete m_pBuffer;
197 }
198 if (m_pBuffer) {
199 delete m_pBuffer;
200 }
201 } 195 }
202 #define FPDF_FILTER_BUFFER_IN_SIZE FPDF_FILTER_BUFFER_SIZE 196 #define FPDF_FILTER_BUFFER_IN_SIZE FPDF_FILTER_BUFFER_SIZE
203 FX_DWORD CPDF_StreamFilter::ReadBlock(uint8_t* buffer, FX_DWORD buf_size) 197 FX_DWORD CPDF_StreamFilter::ReadBlock(uint8_t* buffer, FX_DWORD buf_size)
204 { 198 {
205 if (m_pFilter == NULL) { 199 if (m_pFilter == NULL) {
206 FX_DWORD read_size = m_pStream->GetRawSize() - m_SrcOffset; 200 FX_DWORD read_size = m_pStream->GetRawSize() - m_SrcOffset;
207 if (read_size == 0) { 201 if (read_size == 0) {
208 return 0; 202 return 0;
209 } 203 }
210 if (read_size > buf_size) { 204 if (read_size > buf_size) {
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 } 894 }
901 if (m_bEndOfLine) 895 if (m_bEndOfLine)
902 if (!_FaxSkipEOL(src_buf, bitsize, bitpos)) { 896 if (!_FaxSkipEOL(src_buf, bitsize, bitpos)) {
903 return FALSE; 897 return FALSE;
904 } 898 }
905 if (m_bByteAlign) { 899 if (m_bByteAlign) {
906 bitpos = (bitpos + 7) / 8 * 8; 900 bitpos = (bitpos + 7) / 8 * 8;
907 } 901 }
908 return TRUE; 902 return TRUE;
909 } 903 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698