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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page.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 "pageint.h" 9 #include "pageint.h"
10 CPDF_PageObject* CPDF_PageObject::Create(int type) 10 CPDF_PageObject* CPDF_PageObject::Create(int type)
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 return; 690 return;
691 } 691 }
692 CFX_FloatRect rect = m_ClipPath.GetClipBox(); 692 CFX_FloatRect rect = m_ClipPath.GetClipBox();
693 m_Left = rect.left; 693 m_Left = rect.left;
694 m_Bottom = rect.bottom; 694 m_Bottom = rect.bottom;
695 m_Right = rect.right; 695 m_Right = rect.right;
696 m_Top = rect.top; 696 m_Top = rect.top;
697 } 697 }
698 CPDF_FormObject::~CPDF_FormObject() 698 CPDF_FormObject::~CPDF_FormObject()
699 { 699 {
700 if (m_pForm) { 700 delete m_pForm;
701 delete m_pForm;
702 }
703 } 701 }
704 void CPDF_FormObject::Transform(const CFX_AffineMatrix& matrix) 702 void CPDF_FormObject::Transform(const CFX_AffineMatrix& matrix)
705 { 703 {
706 m_FormMatrix.Concat(matrix); 704 m_FormMatrix.Concat(matrix);
707 CalcBoundingBox(); 705 CalcBoundingBox();
708 } 706 }
709 void CPDF_FormObject::CopyData(const CPDF_PageObject* pSrc) 707 void CPDF_FormObject::CopyData(const CPDF_PageObject* pSrc)
710 { 708 {
711 const CPDF_FormObject* pSrcObj = (const CPDF_FormObject*)pSrc; 709 const CPDF_FormObject* pSrcObj = (const CPDF_FormObject*)pSrc;
712 if (m_pForm) { 710 delete m_pForm;
713 delete m_pForm;
714 }
715 m_pForm = pSrcObj->m_pForm->Clone(); 711 m_pForm = pSrcObj->m_pForm->Clone();
716 m_FormMatrix = pSrcObj->m_FormMatrix; 712 m_FormMatrix = pSrcObj->m_FormMatrix;
717 } 713 }
718 void CPDF_FormObject::CalcBoundingBox() 714 void CPDF_FormObject::CalcBoundingBox()
719 { 715 {
720 CFX_FloatRect form_rect = m_pForm->CalcBoundingBox(); 716 CFX_FloatRect form_rect = m_pForm->CalcBoundingBox();
721 form_rect.Transform(&m_FormMatrix); 717 form_rect.Transform(&m_FormMatrix);
722 m_Left = form_rect.left; 718 m_Left = form_rect.left;
723 m_Bottom = form_rect.bottom; 719 m_Bottom = form_rect.bottom;
724 m_Right = form_rect.right; 720 m_Right = form_rect.right;
725 m_Top = form_rect.top; 721 m_Top = form_rect.top;
726 } 722 }
727 CPDF_PageObjects::CPDF_PageObjects(FX_BOOL bReleaseMembers) : m_ObjectList(128) 723 CPDF_PageObjects::CPDF_PageObjects(FX_BOOL bReleaseMembers) : m_ObjectList(128)
728 { 724 {
729 m_bBackgroundAlphaNeeded = FALSE; 725 m_bBackgroundAlphaNeeded = FALSE;
730 m_bReleaseMembers = bReleaseMembers; 726 m_bReleaseMembers = bReleaseMembers;
731 m_ParseState = PDF_CONTENT_NOT_PARSED; 727 m_ParseState = PDF_CONTENT_NOT_PARSED;
732 m_pParser = NULL; 728 m_pParser = NULL;
733 m_pFormStream = NULL; 729 m_pFormStream = NULL;
734 m_pResources = NULL; 730 m_pResources = NULL;
735 } 731 }
736 CPDF_PageObjects::~CPDF_PageObjects() 732 CPDF_PageObjects::~CPDF_PageObjects()
737 { 733 {
738 if (m_pParser) { 734 delete m_pParser;
739 delete m_pParser;
740 }
741 if (!m_bReleaseMembers) { 735 if (!m_bReleaseMembers) {
742 return; 736 return;
743 } 737 }
744 FX_POSITION pos = m_ObjectList.GetHeadPosition(); 738 FX_POSITION pos = m_ObjectList.GetHeadPosition();
745 while (pos) { 739 while (pos) {
746 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); 740 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos);
747 } 741 }
748 } 742 }
749 void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause) 743 void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause)
750 { 744 {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 if (pGroup->GetInteger(FX_BSTRC("I"))) { 838 if (pGroup->GetInteger(FX_BSTRC("I"))) {
845 m_Transparency |= PDFTRANS_ISOLATED; 839 m_Transparency |= PDFTRANS_ISOLATED;
846 } 840 }
847 if (pGroup->GetInteger(FX_BSTRC("K"))) { 841 if (pGroup->GetInteger(FX_BSTRC("K"))) {
848 m_Transparency |= PDFTRANS_KNOCKOUT; 842 m_Transparency |= PDFTRANS_KNOCKOUT;
849 } 843 }
850 } 844 }
851 void CPDF_PageObjects::ClearCacheObjects() 845 void CPDF_PageObjects::ClearCacheObjects()
852 { 846 {
853 m_ParseState = PDF_CONTENT_NOT_PARSED; 847 m_ParseState = PDF_CONTENT_NOT_PARSED;
854 if (m_pParser) { 848 delete m_pParser;
855 delete m_pParser;
856 }
857 m_pParser = NULL; 849 m_pParser = NULL;
858 if (m_bReleaseMembers) { 850 if (m_bReleaseMembers) {
859 FX_POSITION pos = m_ObjectList.GetHeadPosition(); 851 FX_POSITION pos = m_ObjectList.GetHeadPosition();
860 while (pos) { 852 while (pos) {
861 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos); 853 delete (CPDF_PageObject*)m_ObjectList.GetNext(pos);
862 } 854 }
863 } 855 }
864 m_ObjectList.RemoveAll(); 856 m_ObjectList.RemoveAll();
865 } 857 }
866 CPDF_Page::CPDF_Page() 858 CPDF_Page::CPDF_Page()
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 matrix = m_PageMatrix; 1069 matrix = m_PageMatrix;
1078 matrix.Concat(display_matrix); 1070 matrix.Concat(display_matrix);
1079 } 1071 }
1080 CPDF_ParseOptions::CPDF_ParseOptions() 1072 CPDF_ParseOptions::CPDF_ParseOptions()
1081 { 1073 {
1082 m_bTextOnly = FALSE; 1074 m_bTextOnly = FALSE;
1083 m_bMarkedContent = TRUE; 1075 m_bMarkedContent = TRUE;
1084 m_bSeparateForm = TRUE; 1076 m_bSeparateForm = TRUE;
1085 m_bDecodeInlineImage = FALSE; 1077 m_bDecodeInlineImage = FALSE;
1086 } 1078 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_font/ttgsubtable.h ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698