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

Unified Diff: core/src/fxge/win32/fx_win32_dib.cpp

Issue 1145843005: Revert "Remove FX_Alloc() null checks now that it can't return NULL." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fxge/win32/fx_win32_device.cpp ('k') | core/src/fxge/win32/fx_win32_gdipext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxge/win32/fx_win32_dib.cpp
diff --git a/core/src/fxge/win32/fx_win32_dib.cpp b/core/src/fxge/win32/fx_win32_dib.cpp
index 46abdb366c8f99688566e26bcc5f42b26d534b64..ec523c39c1dba6c2184d6249e70b2385c4b6b89f 100644
--- a/core/src/fxge/win32/fx_win32_dib.cpp
+++ b/core/src/fxge/win32/fx_win32_dib.cpp
@@ -69,6 +69,12 @@ CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData, FX_BOOL
FXSYS_memcpy32(pBitmap->GetBuffer(), pData, pitch * height);
if (bBottomUp) {
FX_LPBYTE temp_buf = FX_Alloc(FX_BYTE, pitch);
+ if (!temp_buf) {
+ if (pBitmap) {
+ delete pBitmap;
+ }
+ return NULL;
+ }
int top = 0, bottom = height - 1;
while (top < bottom) {
FXSYS_memcpy32(temp_buf, pBitmap->GetBuffer() + top * pitch, pitch);
@@ -197,6 +203,13 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, HBITMAP hBitmap, FX_DWORD* pP
size += sizeof (FX_DWORD) * 254;
}
BITMAPINFO* pbmih = (BITMAPINFO*)FX_Alloc(FX_BYTE, size);
+ if (!pbmih) {
+ delete pDIBitmap;
+ if (bCreatedDC) {
+ DeleteDC(hDC);
+ }
+ return NULL;
+ }
pbmih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmih->bmiHeader.biBitCount = bmih.biBitCount;
pbmih->bmiHeader.biCompression = BI_RGB;
« no previous file with comments | « core/src/fxge/win32/fx_win32_device.cpp ('k') | core/src/fxge/win32/fx_win32_gdipext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698