Revert "Remove FX_Alloc() null checks now that it can't return NULL."
[pdfium.git] / core / src / fxge / win32 / fx_win32_gdipext.cpp
index 0f13721..49c3f2b 100644 (file)
@@ -302,10 +302,7 @@ static CFX_DIBitmap* _StretchMonoToGray(int dest_width, int dest_height,
     int result_width = pClipRect->Width();
     int result_height = pClipRect->Height();
     int result_pitch = (result_width + 3) / 4 * 4;
-    CFX_DIBitmap* pStretched = FX_NEW CFX_DIBitmap;
-    if (!pStretched) {
-        return NULL;
-    }
+    CFX_DIBitmap* pStretched = new CFX_DIBitmap;
     if (!pStretched->Create(result_width, result_height, FXDIB_8bppRgb)) {
         delete pStretched;
         return NULL;
@@ -1008,7 +1005,7 @@ BOOL CGdiplusExt::DrawPath(HDC hDC, const CFX_PathData* pPathData,
     CallFunc(GdipDeleteGraphics)(pGraphics);
     return TRUE;
 }
-class GpStream FX_FINAL : public IStream, public CFX_Object
+class GpStream FX_FINAL : public IStream
 {
     LONG       m_RefCount;
     int     m_ReadPos;
@@ -1164,10 +1161,7 @@ static PREVIEW3_DIBITMAP* LoadDIBitmap(WINDIB_Open_Args_ args)
         if (args.memory_size == 0 || !args.memory_base) {
             return NULL;
         }
-        pStream = FX_NEW GpStream;
-        if (!pStream) {
-            return NULL;
-        }
+        pStream = new GpStream;
         pStream->Write(args.memory_base, (ULONG)args.memory_size, NULL);
         status = CallFunc(GdipCreateBitmapFromStreamICM)(pStream, &pBitmap);
     }
@@ -1272,16 +1266,14 @@ CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args)
     int height = abs(pInfo->pbmi->bmiHeader.biHeight);
     int width = pInfo->pbmi->bmiHeader.biWidth;
     int dest_pitch = (width * pInfo->pbmi->bmiHeader.biBitCount + 31) / 32 * 4;
-    LPBYTE pData = FX_Alloc(BYTE, dest_pitch * height);
-    if (pData == NULL) {
-        FreeDIBitmap(pInfo);
-        return NULL;
-    }
+    LPBYTE pData = FX_Alloc2D(BYTE, dest_pitch, height);
     if (dest_pitch == pInfo->Stride) {
         FXSYS_memcpy32(pData, pInfo->pScan0, dest_pitch * height);
-    } else for (int i = 0; i < height; i ++) {
+    } else {
+        for (int i = 0; i < height; i ++) {
             FXSYS_memcpy32(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i, dest_pitch);
         }
+    }
     CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf(pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32);
     FX_Free(pData);
     FreeDIBitmap(pInfo);