Index: core/fpdfapi/fpdf_render/fpdf_render_image.cpp |
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp |
index e23cab3546c57eaa5076d292ea01db2b8b3ba97a..c9cd98a7af164b2c78a0a1bdd3dff5d230750608 100644 |
--- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp |
+++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp |
@@ -762,9 +762,15 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { |
FX_BOOL CPDF_ImageRenderer::StartDIBSource() { |
if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { |
- int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() * |
- m_pDIBSource->GetHeight(); |
- if (image_size > FPDF_HUGE_IMAGE_SIZE && |
+ FX_SAFE_SIZE_T image_size = m_pDIBSource->GetBPP(); |
+ image_size /= 8; |
+ image_size *= m_pDIBSource->GetWidth(); |
+ image_size *= m_pDIBSource->GetHeight(); |
+ if (!image_size.IsValid()) { |
+ return FALSE; |
+ } |
+ |
+ if (image_size.ValueOrDie() > FPDF_HUGE_IMAGE_SIZE && |
!(m_Flags & RENDER_FORCE_HALFTONE)) { |
m_Flags |= RENDER_FORCE_DOWNSAMPLE; |
} |