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

Side by Side Diff: core/src/fxge/win32/fx_win32_device.cpp

Issue 432543002: Fix integer overflow when stretching bitmap for printing (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Use FX_INT64 Created 6 years, 4 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 "../../../include/fxge/fx_ge.h" 7 #include "../../../include/fxge/fx_ge.h"
8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ 8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_
9 #include "../../../include/fxge/fx_ge_win32.h" 9 #include "../../../include/fxge/fx_ge_win32.h"
10 #include <crtdbg.h> 10 #include <crtdbg.h>
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 { 516 {
517 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; 517 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
518 if (pBitmap == NULL) { 518 if (pBitmap == NULL) {
519 return FALSE; 519 return FALSE;
520 } 520 }
521 if ((pBitmap->IsCmykImage() || pIccTransform) && 521 if ((pBitmap->IsCmykImage() || pIccTransform) &&
522 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) { 522 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) {
523 return FALSE; 523 return FALSE;
524 } 524 }
525 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); 525 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
526 if (abs(dest_width) * abs(dest_height) < pBitmap1->GetWidth() * pBitmap1->Ge tHeight() * 4 || 526 if ((FX_INT64)abs(dest_width) * abs(dest_height) < (FX_INT64)pBitmap1->GetWi dth() * pBitmap1->GetHeight() * 4 ||
527 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) { 527 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) {
528 SetStretchBltMode(m_hDC, HALFTONE); 528 SetStretchBltMode(m_hDC, HALFTONE);
529 } else { 529 } else {
530 SetStretchBltMode(m_hDC, COLORONCOLOR); 530 SetStretchBltMode(m_hDC, COLORONCOLOR);
531 } 531 }
532 CFX_DIBitmap* pToStrechBitmap = pBitmap; 532 CFX_DIBitmap* pToStrechBitmap = pBitmap;
533 bool del = false; 533 bool del = false;
534 if (m_DeviceClass == FXDC_PRINTER && (pBitmap->GetWidth() * pBitmap->GetHeig ht() > abs(dest_width) * abs(dest_height))) { 534 if (m_DeviceClass == FXDC_PRINTER && ((FX_INT64)pBitmap->GetWidth() * pBitma p->GetHeight() > (FX_INT64)abs(dest_width) * abs(dest_height))) {
535 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); 535 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height);
536 del = true; 536 del = true;
537 } 537 }
538 CFX_ByteString toStrechBitmapInfo = CFX_WindowsDIB::GetBitmapInfo(pToStrechB itmap); 538 CFX_ByteString toStrechBitmapInfo = CFX_WindowsDIB::GetBitmapInfo(pToStrechB itmap);
539 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 539 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height,
540 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeigh t(), pToStrechBitmap->GetBuffer(), 540 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeigh t(), pToStrechBitmap->GetBuffer(),
541 (BITMAPINFO*)(FX_LPCSTR)toStrechBitmapInfo, DIB_RGB_COLORS, SRCCOPY); 541 (BITMAPINFO*)(FX_LPCSTR)toStrechBitmapInfo, DIB_RGB_COLORS, SRCCOPY);
542 if (del) { 542 if (del) {
543 delete pToStrechBitmap; 543 delete pToStrechBitmap;
544 } 544 }
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 if (m_hDC) { 1191 if (m_hDC) {
1192 SelectObject(m_hDC, m_hOldBitmap); 1192 SelectObject(m_hDC, m_hOldBitmap);
1193 DeleteDC(m_hDC); 1193 DeleteDC(m_hDC);
1194 } 1194 }
1195 if (m_hBitmap) { 1195 if (m_hBitmap) {
1196 DeleteObject(m_hBitmap); 1196 DeleteObject(m_hBitmap);
1197 } 1197 }
1198 delete GetBitmap(); 1198 delete GetBitmap();
1199 } 1199 }
1200 #endif 1200 #endif
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