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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.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
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 <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "../../../include/fpdfapi/fpdf_module.h" 10 #include "../../../include/fpdfapi/fpdf_module.h"
(...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 m_pFileAccess = NULL; 1725 m_pFileAccess = NULL;
1726 m_pCryptoHandler = NULL; 1726 m_pCryptoHandler = NULL;
1727 m_pFileBuf = NULL; 1727 m_pFileBuf = NULL;
1728 m_BufSize = CPDF_ModuleMgr::kFileBufSize; 1728 m_BufSize = CPDF_ModuleMgr::kFileBufSize;
1729 m_pFileBuf = NULL; 1729 m_pFileBuf = NULL;
1730 m_MetadataObjnum = 0; 1730 m_MetadataObjnum = 0;
1731 m_dwWordPos = 0; 1731 m_dwWordPos = 0;
1732 m_bFileStream = FALSE; 1732 m_bFileStream = FALSE;
1733 } 1733 }
1734 CPDF_SyntaxParser::~CPDF_SyntaxParser() { 1734 CPDF_SyntaxParser::~CPDF_SyntaxParser() {
1735 if (m_pFileBuf) { 1735 FX_Free(m_pFileBuf);
1736 FX_Free(m_pFileBuf);
1737 }
1738 } 1736 }
1739 FX_BOOL CPDF_SyntaxParser::GetCharAt(FX_FILESIZE pos, uint8_t& ch) { 1737 FX_BOOL CPDF_SyntaxParser::GetCharAt(FX_FILESIZE pos, uint8_t& ch) {
1740 FX_FILESIZE save_pos = m_Pos; 1738 FX_FILESIZE save_pos = m_Pos;
1741 m_Pos = pos; 1739 m_Pos = pos;
1742 FX_BOOL ret = GetNextChar(ch); 1740 FX_BOOL ret = GetNextChar(ch);
1743 m_Pos = save_pos; 1741 m_Pos = save_pos;
1744 return ret; 1742 return ret;
1745 } 1743 }
1746 FX_BOOL CPDF_SyntaxParser::GetNextChar(uint8_t& ch) { 1744 FX_BOOL CPDF_SyntaxParser::GetNextChar(uint8_t& ch) {
1747 FX_FILESIZE pos = m_Pos + m_HeaderOffset; 1745 FX_FILESIZE pos = m_Pos + m_HeaderOffset;
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
2582 GetNextWord(); 2580 GetNextWord();
2583 numMarkers = ReadEOLMarkers(m_Pos); 2581 numMarkers = ReadEOLMarkers(m_Pos);
2584 if (m_WordSize == ENDOBJ_LEN && numMarkers != 0 && 2582 if (m_WordSize == ENDOBJ_LEN && numMarkers != 0 &&
2585 FXSYS_memcmp(m_WordBuffer, "endobj", ENDOBJ_LEN) == 0) { 2583 FXSYS_memcmp(m_WordBuffer, "endobj", ENDOBJ_LEN) == 0) {
2586 m_Pos = streamStartPos; 2584 m_Pos = streamStartPos;
2587 } 2585 }
2588 return pStream; 2586 return pStream;
2589 } 2587 }
2590 void CPDF_SyntaxParser::InitParser(IFX_FileRead* pFileAccess, 2588 void CPDF_SyntaxParser::InitParser(IFX_FileRead* pFileAccess,
2591 FX_DWORD HeaderOffset) { 2589 FX_DWORD HeaderOffset) {
2592 if (m_pFileBuf) { 2590 FX_Free(m_pFileBuf);
2593 FX_Free(m_pFileBuf);
2594 m_pFileBuf = NULL;
2595 }
2596 m_pFileBuf = FX_Alloc(uint8_t, m_BufSize); 2591 m_pFileBuf = FX_Alloc(uint8_t, m_BufSize);
2597 m_HeaderOffset = HeaderOffset; 2592 m_HeaderOffset = HeaderOffset;
2598 m_FileLen = pFileAccess->GetSize(); 2593 m_FileLen = pFileAccess->GetSize();
2599 m_Pos = 0; 2594 m_Pos = 0;
2600 m_pFileAccess = pFileAccess; 2595 m_pFileAccess = pFileAccess;
2601 m_BufOffset = 0; 2596 m_BufOffset = 0;
2602 pFileAccess->ReadBlock( 2597 pFileAccess->ReadBlock(
2603 m_pFileBuf, 0, 2598 m_pFileBuf, 0,
2604 (size_t)((FX_FILESIZE)m_BufSize > m_FileLen ? m_FileLen : m_BufSize)); 2599 (size_t)((FX_FILESIZE)m_BufSize > m_FileLen ? m_FileLen : m_BufSize));
2605 } 2600 }
(...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after
4713 return FALSE; 4708 return FALSE;
4714 } 4709 }
4715 CPDF_PageNode::~CPDF_PageNode() { 4710 CPDF_PageNode::~CPDF_PageNode() {
4716 int32_t iSize = m_childNode.GetSize(); 4711 int32_t iSize = m_childNode.GetSize();
4717 for (int32_t i = 0; i < iSize; ++i) { 4712 for (int32_t i = 0; i < iSize; ++i) {
4718 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; 4713 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i];
4719 delete pNode; 4714 delete pNode;
4720 } 4715 }
4721 m_childNode.RemoveAll(); 4716 m_childNode.RemoveAll();
4722 } 4717 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp ('k') | core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698