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

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

Issue 1143663004: Add safe FX_Alloc2D() macro (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Drop one file, indent. Created 5 years, 7 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 | « core/src/fxge/skia/fx_skia_device.cpp ('k') | 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 <windows.h> 9 #include <windows.h>
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData, FX_BOOL bAlpha); 1259 CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData, FX_BOOL bAlpha);
1260 CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) 1260 CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args)
1261 { 1261 {
1262 PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args); 1262 PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args);
1263 if (pInfo == NULL) { 1263 if (pInfo == NULL) {
1264 return NULL; 1264 return NULL;
1265 } 1265 }
1266 int height = abs(pInfo->pbmi->bmiHeader.biHeight); 1266 int height = abs(pInfo->pbmi->bmiHeader.biHeight);
1267 int width = pInfo->pbmi->bmiHeader.biWidth; 1267 int width = pInfo->pbmi->bmiHeader.biWidth;
1268 int dest_pitch = (width * pInfo->pbmi->bmiHeader.biBitCount + 31) / 32 * 4; 1268 int dest_pitch = (width * pInfo->pbmi->bmiHeader.biBitCount + 31) / 32 * 4;
1269 LPBYTE pData = FX_Alloc(BYTE, dest_pitch * height); 1269 LPBYTE pData = FX_Alloc2D(BYTE, dest_pitch, height);
1270 if (pData == NULL) {
1271 FreeDIBitmap(pInfo);
1272 return NULL;
1273 }
1274 if (dest_pitch == pInfo->Stride) { 1270 if (dest_pitch == pInfo->Stride) {
1275 FXSYS_memcpy32(pData, pInfo->pScan0, dest_pitch * height); 1271 FXSYS_memcpy32(pData, pInfo->pScan0, dest_pitch * height);
1276 } else for (int i = 0; i < height; i ++) { 1272 } else {
1273 for (int i = 0; i < height; i ++) {
1277 FXSYS_memcpy32(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i, dest_pitch); 1274 FXSYS_memcpy32(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i, dest_pitch);
1278 } 1275 }
1276 }
1279 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf(pInfo->pbmi, pData, pIn fo->pbmi->bmiHeader.biBitCount == 32); 1277 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf(pInfo->pbmi, pData, pIn fo->pbmi->bmiHeader.biBitCount == 32);
1280 FX_Free(pData); 1278 FX_Free(pData);
1281 FreeDIBitmap(pInfo); 1279 FreeDIBitmap(pInfo);
1282 return pDIBitmap; 1280 return pDIBitmap;
1283 } 1281 }
1284 #endif 1282 #endif
OLDNEW
« no previous file with comments | « core/src/fxge/skia/fx_skia_device.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698