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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/fpdf_render/render_int.h" 7 #include "core/fpdfapi/fpdf_render/render_int.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 } 755 }
756 } 756 }
757 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( 757 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend(
758 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); 758 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType);
759 #endif // _SKIA_SUPPORT_ 759 #endif // _SKIA_SUPPORT_
760 return FALSE; 760 return FALSE;
761 } 761 }
762 762
763 FX_BOOL CPDF_ImageRenderer::StartDIBSource() { 763 FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
764 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { 764 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) {
765 int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() * 765 FX_SAFE_SIZE_T image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWi dth() *
Oliver Chang 2016/09/12 16:21:33 This is incorrect, as any integer errors would've
766 m_pDIBSource->GetHeight(); 766 m_pDIBSource->GetHeight();
767 if (image_size > FPDF_HUGE_IMAGE_SIZE && 767 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
768 !(m_Flags & RENDER_FORCE_HALFTONE)) { 768 !(m_Flags & RENDER_FORCE_HALFTONE)) {
769 m_Flags |= RENDER_FORCE_DOWNSAMPLE; 769 m_Flags |= RENDER_FORCE_DOWNSAMPLE;
770 } 770 }
771 } 771 }
772 #ifdef _SKIA_SUPPORT_ 772 #ifdef _SKIA_SUPPORT_
773 CFX_DIBitmap* premultiplied = m_pDIBSource->Clone(); 773 CFX_DIBitmap* premultiplied = m_pDIBSource->Clone();
774 if (m_pDIBSource->HasAlpha()) 774 if (m_pDIBSource->HasAlpha())
775 CFX_SkiaDeviceDriver::PreMultiply(premultiplied); 775 CFX_SkiaDeviceDriver::PreMultiply(premultiplied);
776 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( 776 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend(
777 premultiplied, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, 777 premultiplied, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags,
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 } else if (pFunc) { 1070 } else if (pFunc) {
1071 int size = dest_pitch * height; 1071 int size = dest_pitch * height;
1072 for (int i = 0; i < size; i++) { 1072 for (int i = 0; i < size; i++) {
1073 dest_buf[i] = transfers[src_buf[i]]; 1073 dest_buf[i] = transfers[src_buf[i]];
1074 } 1074 }
1075 } else { 1075 } else {
1076 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); 1076 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height);
1077 } 1077 }
1078 return pMask.release(); 1078 return pMask.release();
1079 } 1079 }
OLDNEW
« 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