diff options
author | Lei Zhang <thestig@chromium.org> | 2017-12-22 00:30:04 -0800 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-12-22 19:44:07 +0000 |
commit | 05dcbc931eacb72f1a11835ae282fc8434b7a434 (patch) | |
tree | d05902195813a9760e6d90f5189c2dd421676975 /core/fpdfapi/page/cpdf_patterncs.cpp | |
parent | 891aaf63b3490989a189bcc51b18647073f988d4 (diff) | |
download | pdfium-05dcbc931eacb72f1a11835ae282fc8434b7a434.tar.xz |
Only set CPDF_ColorSpace component count on successful load.chromium/3310chromium/3309chromium/3308chromium/3307chromium/3306chromium/3305chromium/3304chromium/3303chromium/3302
Make sure all CPDF_ColorSpace instances consistently call v_Load().
Change-Id: I15c1608c36781a03131884abceff1ecc4a9a1eb1
Reviewed-on: https://pdfium-review.googlesource.com/21911
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_patterncs.cpp')
-rw-r--r-- | core/fpdfapi/page/cpdf_patterncs.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/core/fpdfapi/page/cpdf_patterncs.cpp b/core/fpdfapi/page/cpdf_patterncs.cpp index d14a2c1976..b4b680f026 100644 --- a/core/fpdfapi/page/cpdf_patterncs.cpp +++ b/core/fpdfapi/page/cpdf_patterncs.cpp @@ -11,7 +11,7 @@ #include "core/fpdfapi/parser/cpdf_document.h" CPDF_PatternCS::CPDF_PatternCS(CPDF_Document* pDoc) - : CPDF_ColorSpace(pDoc, PDFCS_PATTERN, 1), + : CPDF_ColorSpace(pDoc, PDFCS_PATTERN), m_pBaseCS(nullptr), m_pCountedBaseCS(nullptr) {} @@ -24,32 +24,36 @@ CPDF_PatternCS::~CPDF_PatternCS() { } } -bool CPDF_PatternCS::v_Load(CPDF_Document* pDoc, - CPDF_Array* pArray, - std::set<CPDF_Object*>* pVisited) { +void CPDF_PatternCS::InitializeStockPattern() { + SetComponentsForStockCS(1); +} + +uint32_t CPDF_PatternCS::v_Load(CPDF_Document* pDoc, + CPDF_Array* pArray, + std::set<CPDF_Object*>* pVisited) { CPDF_Object* pBaseCS = pArray->GetDirectObjectAt(1); if (pBaseCS == m_pArray) - return false; + return 0; CPDF_DocPageData* pDocPageData = pDoc->GetPageData(); m_pBaseCS = pDocPageData->GetColorSpaceGuarded(pBaseCS, nullptr, pVisited); - if (!m_pBaseCS) { - m_nComponents = 1; - return true; - } + if (!m_pBaseCS) + return 1; if (m_pBaseCS->GetFamily() == PDFCS_PATTERN) - return false; + return 0; m_pCountedBaseCS = pDocPageData->FindColorSpacePtr(m_pBaseCS->GetArray()); - m_nComponents = m_pBaseCS->CountComponents() + 1; - return m_pBaseCS->CountComponents() <= kMaxPatternColorComps; + if (m_pBaseCS->CountComponents() > kMaxPatternColorComps) + return 0; + + return m_pBaseCS->CountComponents() + 1; } bool CPDF_PatternCS::GetRGB(float* pBuf, float* R, float* G, float* B) const { if (m_pBaseCS) { ASSERT(m_pBaseCS->GetFamily() != PDFCS_PATTERN); - PatternValue* pvalue = (PatternValue*)pBuf; + PatternValue* pvalue = reinterpret_cast<PatternValue*>(pBuf); if (m_pBaseCS->GetRGB(pvalue->m_Comps, R, G, B)) return true; } |