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

Unified Diff: core/fpdfapi/fpdf_render/fpdf_render_image.cpp

Issue 2323663002: Fix compare between signed and unsigned values in CPDF_ImageRenderer::StartDIBSource. (Closed)
Patch Set: Use FX_SAFE_SIZE_T instead of size_t Created 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d0da0bed5e30902a7e6e3da8091a16348e24ccdd 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -762,9 +762,9 @@ 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() / 8 * m_pDIBSource->GetWidth() *
Oliver Chang 2016/09/12 16:21:33 This is incorrect, as any integer errors would've
+ m_pDIBSource->GetHeight();
+ if (image_size.ValueOrDie() > FPDF_HUGE_IMAGE_SIZE &&
Oliver Chang 2016/09/12 16:21:33 Usually we don't want to crash if image_size is no
!(m_Flags & RENDER_FORCE_HALFTONE)) {
m_Flags |= RENDER_FORCE_DOWNSAMPLE;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698