Lab colorspace needs to be 3 component
authorBo Xu <bo_xu@foxitsoftware.com>
Thu, 11 Dec 2014 00:00:29 +0000 (16:00 -0800)
committerBo Xu <bo_xu@foxitsoftware.com>
Thu, 11 Dec 2014 00:00:29 +0000 (16:00 -0800)
BUG=429134
R=tsepez@chromium.org

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

core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp

index 5266c1a..6704656 100644 (file)
@@ -456,6 +456,7 @@ FX_BOOL CPDF_LabCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
 }
 void CPDF_LabCS::GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOAT& max) const
 {
+    assert(iComponent < 3);
     value = 0;
     if (iComponent == 0) {
         min = 0;
index d2910dc..c5a96d6 100644 (file)
@@ -583,6 +583,10 @@ int CPDF_DIBSource::CreateDecoder()
                 if (m_nComponents != comps) {
                     FX_Free(m_pCompData);
                     m_nComponents = comps;
+                    if (m_Family == PDFCS_LAB && m_nComponents != 3) {
+                        m_pCompData = NULL;
+                        return 0;
+                    }
                     m_pCompData = GetDecodeAndMaskArray(m_bDefaultDecode, m_bColorKey);
                     if (m_pCompData == NULL) {
                         return 0;