Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2125)

Unified Diff: core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp

Issue 534763002: Check m_nComponents when using JBIG2Decode (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Add missing check Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_render/render_int.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f3a1996ab4aa60278db44e9ea2719ece3467135b..cd81b2edebd1f04eab5174571f2d6bbfbf16d102 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -317,11 +317,9 @@ 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) {
return 0;
}
-
FX_SAFE_DWORD src_pitch = m_bpc;
src_pitch *= m_nComponents;
src_pitch *= m_Width;
@@ -331,16 +329,12 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, const CPDF_Stream* p
if (!src_pitch.IsValid()) {
return 0;
}
-
m_pStreamAcc = FX_NEW CPDF_StreamAcc;
m_pStreamAcc->LoadAllData(pStream, FALSE, src_pitch.ValueOrDie(), TRUE);
if (m_pStreamAcc->GetSize() == 0 || m_pStreamAcc->GetData() == NULL) {
return 0;
}
const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder();
- if (!decoder.IsEmpty() && decoder == FX_BSTRC("CCITTFaxDecode")) {
- m_bpc = 1;
- }
int ret = CreateDecoder();
if (ret != 1) {
if (!ret) {
@@ -450,8 +444,6 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause)
}
FX_BOOL CPDF_DIBSource::LoadColorInfo(CPDF_Dictionary* pFormResources, CPDF_Dictionary* pPageResources)
{
- m_bpc_orig = m_pDict->GetInteger(FX_BSTRC("BitsPerComponent"));
- ValidateBpc();
if (m_pDict->GetInteger("ImageMask")) {
m_bImageMask = TRUE;
}
@@ -505,6 +497,8 @@ FX_BOOL CPDF_DIBSource::LoadColorInfo(CPDF_Dictionary* pFormResources, CPDF_Dict
m_nComponents = 4;
}
}
+ m_bpc_orig = m_pDict->GetInteger(FX_BSTRC("BitsPerComponent"));
Tom Sepez 2014/09/02 22:11:54 Maybe this assignment goes as the first line of Va
Bo Xu 2014/09/02 22:27:13 Done.
+ ValidateDictParam();
m_pCompData = FX_Alloc(DIB_COMP_DATA, m_nComponents);
if (m_bpc == 0) {
return TRUE;
@@ -915,7 +909,7 @@ void CPDF_DIBSource::LoadPalette()
}
}
}
-void CPDF_DIBSource::ValidateBpc()
+void CPDF_DIBSource::ValidateDictParam()
{
m_bpc = m_bpc_orig;
CPDF_Object * pFilter = m_pDict ? m_pDict->GetElementValue(FX_BSTRC("Filter")) : NULL;
Tom Sepez 2014/09/02 22:11:54 nit: we de-ref'd m_pDict just before calling this
Bo Xu 2014/09/02 22:27:13 Now check m_pDict in CPDF_DIBSource::Load to make
@@ -924,6 +918,7 @@ void CPDF_DIBSource::ValidateBpc()
CFX_ByteString filter = pFilter->GetString();
if (filter == FX_BSTRC("CCITTFaxDecode") || filter == FX_BSTRC("JBIG2Decode")) {
m_bpc = 1;
+ m_nComponents = 1;
}
if (filter == FX_BSTRC("RunLengthDecode") || filter == FX_BSTRC("DCTDecode")) {
m_bpc = 8;
@@ -933,6 +928,7 @@ void CPDF_DIBSource::ValidateBpc()
if (pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("CCITTFacDecode") ||
pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("JBIG2Decode")) {
m_bpc = 1;
+ m_nComponents = 1;
}
if (pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("RunLengthDecode") ||
pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("DCTDecode")) {
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_render/render_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698