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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_colors.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
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp » ('j') | 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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 FX_BOOL bTransMask = FALSE) const override; 664 FX_BOOL bTransMask = FALSE) const override;
665 665
666 CPDF_ColorSpace* m_pAlterCS; 666 CPDF_ColorSpace* m_pAlterCS;
667 CPDF_IccProfile* m_pProfile; 667 CPDF_IccProfile* m_pProfile;
668 uint8_t* m_pCache; 668 uint8_t* m_pCache;
669 FX_FLOAT* m_pRanges; 669 FX_FLOAT* m_pRanges;
670 FX_BOOL m_bOwn; 670 FX_BOOL m_bOwn;
671 }; 671 };
672 672
673 CPDF_ICCBasedCS::~CPDF_ICCBasedCS() { 673 CPDF_ICCBasedCS::~CPDF_ICCBasedCS() {
674 if (m_pCache) { 674 FX_Free(m_pCache);
675 FX_Free(m_pCache); 675 FX_Free(m_pRanges);
676 }
677 if (m_pRanges) {
678 FX_Free(m_pRanges);
679 }
680 if (m_pAlterCS && m_bOwn) { 676 if (m_pAlterCS && m_bOwn) {
681 m_pAlterCS->ReleaseCS(); 677 m_pAlterCS->ReleaseCS();
682 } 678 }
683 if (m_pProfile && m_pDocument) { 679 if (m_pProfile && m_pDocument) {
684 m_pDocument->GetPageData()->ReleaseIccProfile(m_pProfile); 680 m_pDocument->GetPageData()->ReleaseIccProfile(m_pProfile);
685 } 681 }
686 } 682 }
687 683
688 FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { 684 FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) {
689 CPDF_Stream* pStream = pArray->GetStream(1); 685 CPDF_Stream* pStream = pArray->GetStream(1);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 void EnableStdConversion(FX_BOOL bEnabled) override; 871 void EnableStdConversion(FX_BOOL bEnabled) override;
876 872
877 CPDF_ColorSpace* m_pBaseCS; 873 CPDF_ColorSpace* m_pBaseCS;
878 CPDF_CountedColorSpace* m_pCountedBaseCS; 874 CPDF_CountedColorSpace* m_pCountedBaseCS;
879 int m_nBaseComponents; 875 int m_nBaseComponents;
880 int m_MaxIndex; 876 int m_MaxIndex;
881 CFX_ByteString m_Table; 877 CFX_ByteString m_Table;
882 FX_FLOAT* m_pCompMinMax; 878 FX_FLOAT* m_pCompMinMax;
883 }; 879 };
884 CPDF_IndexedCS::~CPDF_IndexedCS() { 880 CPDF_IndexedCS::~CPDF_IndexedCS() {
885 if (m_pCompMinMax) { 881 FX_Free(m_pCompMinMax);
886 FX_Free(m_pCompMinMax);
887 }
888 CPDF_ColorSpace* pCS = m_pCountedBaseCS ? m_pCountedBaseCS->get() : NULL; 882 CPDF_ColorSpace* pCS = m_pCountedBaseCS ? m_pCountedBaseCS->get() : NULL;
889 if (pCS && m_pDocument) { 883 if (pCS && m_pDocument) {
890 m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray()); 884 m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray());
891 } 885 }
892 } 886 }
893 FX_BOOL CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { 887 FX_BOOL CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) {
894 if (pArray->GetCount() < 4) { 888 if (pArray->GetCount() < 4) {
895 return FALSE; 889 return FALSE;
896 } 890 }
897 CPDF_Object* pBaseObj = pArray->GetElementValue(1); 891 CPDF_Object* pBaseObj = pArray->GetElementValue(1);
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 } 1447 }
1454 if (m_pCS->GetFamily() != PDFCS_PATTERN) { 1448 if (m_pCS->GetFamily() != PDFCS_PATTERN) {
1455 FXSYS_memcpy(m_pBuffer, comps, m_pCS->CountComponents() * sizeof(FX_FLOAT)); 1449 FXSYS_memcpy(m_pBuffer, comps, m_pCS->CountComponents() * sizeof(FX_FLOAT));
1456 } 1450 }
1457 } 1451 }
1458 void CPDF_Color::SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comps, int ncomps) { 1452 void CPDF_Color::SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comps, int ncomps) {
1459 if (ncomps > MAX_PATTERN_COLORCOMPS) { 1453 if (ncomps > MAX_PATTERN_COLORCOMPS) {
1460 return; 1454 return;
1461 } 1455 }
1462 if (m_pCS == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) { 1456 if (m_pCS == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) {
1463 if (m_pBuffer) { 1457 FX_Free(m_pBuffer);
1464 FX_Free(m_pBuffer);
1465 }
1466 m_pCS = CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN); 1458 m_pCS = CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN);
1467 m_pBuffer = m_pCS->CreateBuf(); 1459 m_pBuffer = m_pCS->CreateBuf();
1468 } 1460 }
1469 CPDF_DocPageData* pDocPageData = NULL; 1461 CPDF_DocPageData* pDocPageData = NULL;
1470 PatternValue* pvalue = (PatternValue*)m_pBuffer; 1462 PatternValue* pvalue = (PatternValue*)m_pBuffer;
1471 if (pvalue->m_pPattern && pvalue->m_pPattern->m_pDocument) { 1463 if (pvalue->m_pPattern && pvalue->m_pPattern->m_pDocument) {
1472 pDocPageData = pvalue->m_pPattern->m_pDocument->GetPageData(); 1464 pDocPageData = pvalue->m_pPattern->m_pDocument->GetPageData();
1473 if (pDocPageData) { 1465 if (pDocPageData) {
1474 pDocPageData->ReleasePattern(pvalue->m_pPattern->m_pPatternObj); 1466 pDocPageData->ReleasePattern(pvalue->m_pPattern->m_pPatternObj);
1475 } 1467 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 } 1537 }
1546 PatternValue* pvalue = (PatternValue*)m_pBuffer; 1538 PatternValue* pvalue = (PatternValue*)m_pBuffer;
1547 return pvalue->m_nComps ? pvalue->m_Comps : NULL; 1539 return pvalue->m_nComps ? pvalue->m_Comps : NULL;
1548 } 1540 }
1549 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const { 1541 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const {
1550 if (m_pCS != other.m_pCS || m_pCS == NULL) { 1542 if (m_pCS != other.m_pCS || m_pCS == NULL) {
1551 return FALSE; 1543 return FALSE;
1552 } 1544 }
1553 return FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0; 1545 return FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0;
1554 } 1546 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698