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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_parser.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 "../../../include/fpdfapi/fpdf_page.h" 7 #include "../../../include/fpdfapi/fpdf_page.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fpdfapi/fpdf_serial.h" 9 #include "../../../include/fpdfapi/fpdf_serial.h"
10 #include "pageint.h" 10 #include "pageint.h"
(...skipping 26 matching lines...) Expand all
37 CPDF_StreamContentParser::~CPDF_StreamContentParser() 37 CPDF_StreamContentParser::~CPDF_StreamContentParser()
38 { 38 {
39 ClearAllParams(); 39 ClearAllParams();
40 int i = 0; 40 int i = 0;
41 for (i = 0; i < m_StateStack.GetSize(); i ++) { 41 for (i = 0; i < m_StateStack.GetSize(); i ++) {
42 delete (CPDF_AllStates*)m_StateStack[i]; 42 delete (CPDF_AllStates*)m_StateStack[i];
43 } 43 }
44 if (m_pPathPoints) { 44 if (m_pPathPoints) {
45 FX_Free(m_pPathPoints); 45 FX_Free(m_pPathPoints);
46 } 46 }
47 if (m_pCurStates) { 47 delete m_pCurStates;
48 delete m_pCurStates;
49 }
50 if (m_pLastImageDict) { 48 if (m_pLastImageDict) {
51 m_pLastImageDict->Release(); 49 m_pLastImageDict->Release();
52 } 50 }
53 if (m_pLastCloneImageDict) { 51 if (m_pLastCloneImageDict) {
54 m_pLastCloneImageDict->Release(); 52 m_pLastCloneImageDict->Release();
55 } 53 }
56 } 54 }
57 void CPDF_StreamContentParser::PrepareParse(CPDF_Document* pDocument, 55 void CPDF_StreamContentParser::PrepareParse(CPDF_Document* pDocument,
58 CPDF_Dictionary* pPageResources, CPDF_Dictionary* pParentResources, CFX_ AffineMatrix* pmtContentToUser, CPDF_PageObjects* pObjList, 56 CPDF_Dictionary* pPageResources, CPDF_Dictionary* pParentResources, CFX_ AffineMatrix* pmtContentToUser, CPDF_PageObjects* pObjList,
59 CPDF_Dictionary* pResources, CPDF_Rect* pBBox, CPDF_ParseOptions* pOptio ns, 57 CPDF_Dictionary* pResources, CPDF_Rect* pBBox, CPDF_ParseOptions* pOptio ns,
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 } 792 }
795 void CPDF_StreamContentParser::Handle_EndText() 793 void CPDF_StreamContentParser::Handle_EndText()
796 { 794 {
797 int count = m_ClipTextList.GetSize(); 795 int count = m_ClipTextList.GetSize();
798 if (count == 0) { 796 if (count == 0) {
799 return; 797 return;
800 } 798 }
801 if (m_pCurStates->m_TextState.GetObject()->m_TextMode < 4) { 799 if (m_pCurStates->m_TextState.GetObject()->m_TextMode < 4) {
802 for (int i = 0; i < count; i ++) { 800 for (int i = 0; i < count; i ++) {
803 CPDF_TextObject* pText = (CPDF_TextObject*)m_ClipTextList.GetAt(i); 801 CPDF_TextObject* pText = (CPDF_TextObject*)m_ClipTextList.GetAt(i);
804 if (pText) { 802 delete pText;
805 delete pText;
806 }
807 } 803 }
808 } else { 804 } else {
809 m_pCurStates->m_ClipPath.AppendTexts((CPDF_TextObject**)m_ClipTextList.G etData(), count); 805 m_pCurStates->m_ClipPath.AppendTexts((CPDF_TextObject**)m_ClipTextList.G etData(), count);
810 } 806 }
811 m_ClipTextList.RemoveAll(); 807 m_ClipTextList.RemoveAll();
812 } 808 }
813 void CPDF_StreamContentParser::Handle_EndSectionUndefined() 809 void CPDF_StreamContentParser::Handle_EndSectionUndefined()
814 { 810 {
815 if (m_CompatCount) { 811 if (m_CompatCount) {
816 m_CompatCount --; 812 m_CompatCount --;
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 buf.AppendChar((char)code); 1574 buf.AppendChar((char)code);
1579 } 1575 }
1580 bFirst = !bFirst; 1576 bFirst = !bFirst;
1581 } 1577 }
1582 } 1578 }
1583 if (!bFirst) { 1579 if (!bFirst) {
1584 buf.AppendChar((char)code); 1580 buf.AppendChar((char)code);
1585 } 1581 }
1586 return buf.GetByteString(); 1582 return buf.GetByteString();
1587 } 1583 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698