Chromium Code Reviews| Index: core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp |
| diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp |
| index a805ffa463ed52cd64da9ffce5b23c3c602e1fcd..87b985595de2b4deb480b3ae72583ae81771c596 100644 |
| --- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp |
| +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp |
| @@ -119,6 +119,7 @@ CPDF_DIBSource::CPDF_DIBSource() |
| m_pColorSpace = NULL; |
| m_bDefaultDecode = TRUE; |
| m_bImageMask = FALSE; |
| + m_bDoBpcCheck = TRUE; |
| m_pPalette = NULL; |
| m_pCompData = NULL; |
| m_bColorKey = FALSE; |
| @@ -197,7 +198,7 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc, const CPDF_Stream* pStream, CP |
| if (!LoadColorInfo(m_pStream->GetObjNum() != 0 ? NULL : pFormResources, pPageResources)) { |
| return FALSE; |
| } |
| - if (m_bpc == 0 || m_nComponents == 0) { |
| + if (m_bDoBpcCheck && (m_bpc == 0 || m_nComponents == 0)) { |
| return FALSE; |
| } |
| FX_SAFE_DWORD src_pitch = |
| @@ -211,7 +212,8 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc, const CPDF_Stream* pStream, CP |
| return FALSE; |
| } |
| const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder(); |
| - if (!decoder.IsEmpty() && decoder == FX_BSTRC("CCITTFaxDecode")) { |
| + if (decoder == FX_BSTRC("CCITTFaxDecode")) { |
| + m_bDoBpcCheck = TRUE; |
| m_bpc = 1; |
| } |
| if (!CreateDecoder()) { |
| @@ -316,7 +318,7 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, const CPDF_Stream* p |
| if (!LoadColorInfo(m_pStream->GetObjNum() != 0 ? NULL : pFormResources, pPageResources)) { |
| return 0; |
| } |
| - if (m_bpc == 0 || m_nComponents == 0) { |
| + if (m_bDoBpcCheck && (m_bpc == 0 || m_nComponents == 0)) { |
| return 0; |
| } |
| FX_SAFE_DWORD src_pitch = |
| @@ -329,6 +331,11 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, const CPDF_Stream* p |
| if (m_pStreamAcc->GetSize() == 0 || m_pStreamAcc->GetData() == NULL) { |
| return 0; |
| } |
| + const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder(); |
|
jun_fang
2015/02/11 16:55:24
ValidateDictParam() is used to correct parameters
Lei Zhang
2015/02/13 02:15:37
No we can't. CreateDecoder will fail first because
|
| + if (decoder == FX_BSTRC("CCITTFaxDecode")) { |
| + m_bDoBpcCheck = TRUE; |
| + m_bpc = 1; |
| + } |
| int ret = CreateDecoder(); |
| if (ret != 1) { |
| if (!ret) { |
| @@ -445,12 +452,16 @@ FX_BOOL CPDF_DIBSource::LoadColorInfo(CPDF_Dictionary* pFormResources, CPDF_Dict |
| CFX_ByteString filter; |
| if (pFilter->GetType() == PDFOBJ_NAME) { |
| filter = pFilter->GetString(); |
| - if (filter == FX_BSTRC("JPXDecode")) { |
| + if (filter == FX_BSTRC("JPXDecode") || |
| + filter == FX_BSTRC("CCITTFaxDecode")) { |
|
jun_fang
2015/02/11 16:55:24
Only JPX may not have "ColorSpace". It's no need t
Lei Zhang
2015/02/13 02:15:37
Can you suggest some other way for CCITTFaxDecode
Lei Zhang
2015/02/13 02:51:07
Oh, nevermind. I understand what you are saying.
|
| + m_bDoBpcCheck = FALSE; |
| return TRUE; |
| } |
| } else if (pFilter->GetType() == PDFOBJ_ARRAY) { |
| CPDF_Array* pArray = (CPDF_Array*)pFilter; |
| - if (pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("JPXDecode")) { |
| + if (pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("JPXDecode") || |
| + pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("CCITTFaxDecode")) { |
|
jun_fang
2015/02/11 16:55:24
Only JPX may not have "ColorSpace". It's no need t
|
| + m_bDoBpcCheck = FALSE; |
| return TRUE; |
| } |
| } |
| @@ -560,7 +571,7 @@ int CPDF_DIBSource::CreateDecoder() |
| if (decoder.IsEmpty()) { |
| return 1; |
| } |
| - if (m_bpc == 0) { |
| + if (m_bDoBpcCheck && m_bpc == 0) { |
| return 0; |
| } |
| FX_LPCBYTE src_data = m_pStreamAcc->GetData(); |