summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_render
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2014-08-27 14:19:55 -0700
committerBo Xu <bo_xu@foxitsoftware.com>2014-08-27 14:19:55 -0700
commit405478d3870693fbaf8f17758a760abfd276b2ee (patch)
treefddf746a59842eda2923c68f2c3a925dce430565 /core/src/fpdfapi/fpdf_render
parenta67da71d5922877e1320f482bf86536d862961ed (diff)
downloadpdfium-405478d3870693fbaf8f17758a760abfd276b2ee.tar.xz
Use valid bpc value in LoadPalette() and ContinueToLoadMask()
BUG=408141, 408147 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/508253003
Diffstat (limited to 'core/src/fpdfapi/fpdf_render')
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
index e02c011b86..5f0abde2be 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -253,19 +253,20 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc, const CPDF_Stream* pStream, CP
}
int CPDF_DIBSource::ContinueToLoadMask()
{
+ FX_DWORD bpc = GetValidBpc();
if (m_bImageMask) {
m_bpp = 1;
- m_bpc = 1;
+ bpc = 1;
m_nComponents = 1;
m_AlphaFlag = 1;
- } else if (m_bpc * m_nComponents == 1) {
+ } else if (bpc * m_nComponents == 1) {
m_bpp = 1;
- } else if (m_bpc * m_nComponents <= 8) {
+ } else if (bpc * m_nComponents <= 8) {
m_bpp = 8;
} else {
m_bpp = 24;
}
- if (!m_bpc || !m_nComponents) {
+ if (!bpc || !m_nComponents) {
return 0;
}
FX_SAFE_DWORD pitch = m_Width;
@@ -854,13 +855,17 @@ int CPDF_DIBSource::StartLoadMaskDIB()
}
void CPDF_DIBSource::LoadPalette()
{
- if (m_bpc * m_nComponents > 8) {
+ FX_DWORD bpc = GetValidBpc();
+ if (bpc == 0) {
+ return;
+ }
+ if (bpc * m_nComponents > 8) {
return;
}
if (m_pColorSpace == NULL) {
return;
}
- if (m_bpc * m_nComponents == 1) {
+ if (bpc * m_nComponents == 1) {
if (m_bDefaultDecode && (m_Family == PDFCS_DEVICEGRAY || m_Family == PDFCS_DEVICERGB)) {
return;
}
@@ -884,16 +889,16 @@ void CPDF_DIBSource::LoadPalette()
}
return;
}
- if (m_pColorSpace == CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY) && m_bpc == 8 && m_bDefaultDecode) {
+ if (m_pColorSpace == CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY) && bpc == 8 && m_bDefaultDecode) {
} else {
- int palette_count = 1 << (m_bpc * m_nComponents);
+ int palette_count = 1 << (bpc * m_nComponents);
CFX_FixedBufGrow<FX_FLOAT, 16> color_values(m_nComponents);
FX_FLOAT* color_value = color_values;
for (int i = 0; i < palette_count; i ++) {
int color_data = i;
for (FX_DWORD j = 0; j < m_nComponents; j ++) {
- int encoded_component = color_data % (1 << m_bpc);
- color_data /= 1 << m_bpc;
+ int encoded_component = color_data % (1 << bpc);
+ color_data /= 1 << bpc;
color_value[j] = m_pCompData[j].m_DecodeMin + m_pCompData[j].m_DecodeStep * encoded_component;
}
FX_FLOAT R = 0, G = 0, B = 0;
@@ -937,7 +942,7 @@ FX_DWORD CPDF_DIBSource::GetValidBpc() const
}
}
}
- if (bpc != 1 && bpc != 2 && bpc != 4 && bpc != 8 && bpc != 12 && bpc != 16) {
+ if (bpc != 1 && bpc != 2 && bpc != 4 && bpc != 8 && bpc != 16) {
bpc = 0;
}