For pattern colorspace, its base colorspace should not be a pattern colorspace
authorBo Xu <bo_xu@foxitsoftware.com>
Thu, 21 Aug 2014 22:19:00 +0000 (15:19 -0700)
committerBo Xu <bo_xu@foxitsoftware.com>
Thu, 21 Aug 2014 22:19:00 +0000 (15:19 -0700)
BUG=405588
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/496883002

core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp

index 1b4e7b8..c0a5602 100644 (file)
@@ -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;