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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp

Issue 472653002: No need to release m_pBaseCS in CPDF_IndexedCS and CPDF_PatternCS (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 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 | « no previous file | no next file » | 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/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/fxcodec/fx_codec.h" 9 #include "../../../include/fxcodec/fx_codec.h"
10 #include "pageint.h" 10 #include "pageint.h"
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 m_pBaseCS = NULL; 747 m_pBaseCS = NULL;
748 m_Family = PDFCS_INDEXED; 748 m_Family = PDFCS_INDEXED;
749 m_nComponents = 1; 749 m_nComponents = 1;
750 m_pCompMinMax = NULL; 750 m_pCompMinMax = NULL;
751 } 751 }
752 CPDF_IndexedCS::~CPDF_IndexedCS() 752 CPDF_IndexedCS::~CPDF_IndexedCS()
753 { 753 {
754 if (m_pCompMinMax) { 754 if (m_pCompMinMax) {
755 FX_Free(m_pCompMinMax); 755 FX_Free(m_pCompMinMax);
756 } 756 }
757 CPDF_ColorSpace* pCS = m_pBaseCS;
758 if (pCS && m_pDocument) {
759 m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray());
760 }
761 } 757 }
762 FX_BOOL CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) 758 FX_BOOL CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
763 { 759 {
764 if (pArray->GetCount() < 4) { 760 if (pArray->GetCount() < 4) {
765 return FALSE; 761 return FALSE;
766 } 762 }
767 CPDF_Object* pBaseObj = pArray->GetElementValue(1); 763 CPDF_Object* pBaseObj = pArray->GetElementValue(1);
768 if (pBaseObj == m_pArray) { 764 if (pBaseObj == m_pArray) {
769 return FALSE; 765 return FALSE;
770 } 766 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 FX_FLOAT m_Comps[MAX_PATTERN_COLORCOMPS]; 826 FX_FLOAT m_Comps[MAX_PATTERN_COLORCOMPS];
831 } PatternValue; 827 } PatternValue;
832 CPDF_PatternCS::CPDF_PatternCS() 828 CPDF_PatternCS::CPDF_PatternCS()
833 { 829 {
834 m_Family = PDFCS_PATTERN; 830 m_Family = PDFCS_PATTERN;
835 m_pBaseCS = NULL; 831 m_pBaseCS = NULL;
836 m_nComponents = 1; 832 m_nComponents = 1;
837 } 833 }
838 CPDF_PatternCS::~CPDF_PatternCS() 834 CPDF_PatternCS::~CPDF_PatternCS()
839 { 835 {
840 CPDF_ColorSpace* pCS = m_pBaseCS;
841 if (pCS && m_pDocument) {
842 m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray());
843 }
844 } 836 }
845 FX_BOOL CPDF_PatternCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) 837 FX_BOOL CPDF_PatternCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
846 { 838 {
847 CPDF_Object* pBaseCS = pArray->GetElementValue(1); 839 CPDF_Object* pBaseCS = pArray->GetElementValue(1);
848 if (pBaseCS == m_pArray) { 840 if (pBaseCS == m_pArray) {
849 return FALSE; 841 return FALSE;
850 } 842 }
851 CPDF_DocPageData* pDocPageData = pDoc->GetPageData(); 843 CPDF_DocPageData* pDocPageData = pDoc->GetPageData();
852 m_pBaseCS = pDocPageData->GetColorSpace(pBaseCS, NULL); 844 m_pBaseCS = pDocPageData->GetColorSpace(pBaseCS, NULL);
853 if (m_pBaseCS) { 845 if (m_pBaseCS) {
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 PatternValue* pvalue = (PatternValue*)m_pBuffer; 1390 PatternValue* pvalue = (PatternValue*)m_pBuffer;
1399 return pvalue->m_nComps ? pvalue->m_Comps : NULL; 1391 return pvalue->m_nComps ? pvalue->m_Comps : NULL;
1400 } 1392 }
1401 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const 1393 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const
1402 { 1394 {
1403 if (m_pCS != other.m_pCS || m_pCS == NULL) { 1395 if (m_pCS != other.m_pCS || m_pCS == NULL) {
1404 return FALSE; 1396 return FALSE;
1405 } 1397 }
1406 return FXSYS_memcmp32(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0; 1398 return FXSYS_memcmp32(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0;
1407 } 1399 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698