From 4fb24f37072ebe6bac88ef5c56a7bbcb444c8aec Mon Sep 17 00:00:00 2001 From: Bo Xu Date: Thu, 21 Aug 2014 15:19:00 -0700 Subject: For pattern colorspace, its base colorspace should not be a pattern colorspace BUG=405588 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/496883002 --- core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp index 1b4e7b83a9..c0a5602819 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp @@ -843,6 +843,9 @@ FX_BOOL CPDF_PatternCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) CPDF_DocPageData* pDocPageData = pDoc->GetPageData(); m_pBaseCS = pDocPageData->GetColorSpace(pBaseCS, NULL); if (m_pBaseCS) { + if (m_pBaseCS->GetFamily() == PDFCS_PATTERN) { + return FALSE; + } m_nComponents = m_pBaseCS->CountComponents() + 1; if (m_pBaseCS->CountComponents() > MAX_PATTERN_COLORCOMPS) { return FALSE; @@ -855,9 +858,11 @@ FX_BOOL CPDF_PatternCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) FX_BOOL CPDF_PatternCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const { if (m_pBaseCS) { + ASSERT(m_pBaseCS->GetFamily() != PDFCS_PATTERN); PatternValue* pvalue = (PatternValue*)pBuf; - m_pBaseCS->GetRGB(pvalue->m_Comps, R, G, B); - return TRUE; + if (m_pBaseCS->GetRGB(pvalue->m_Comps, R, G, B)) { + return TRUE; + } } R = G = B = 0.75f; return FALSE; -- cgit v1.2.3