- Make sure memory allocation succeeded
authorCameron Gutman <aicommander@gmail.com>
Sun, 7 Sep 2008 22:28:19 +0000 (22:28 +0000)
committerCameron Gutman <aicommander@gmail.com>
Sun, 7 Sep 2008 22:28:19 +0000 (22:28 +0000)
svn path=/trunk/; revision=36043

reactos/subsystems/win32/win32k/dib/dib16bpp.c
reactos/subsystems/win32/win32k/dib/dib32bpp.c
reactos/subsystems/win32/win32k/dib/dib8bpp.c
reactos/subsystems/win32/win32k/objects/dc.c

index d3a5f27..0428536 100644 (file)
@@ -626,6 +626,13 @@ BOOLEAN ScaleRectAvg16(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
 
     ScanLineAhead = (PIXEL *)ExAllocatePool(PagedPool, (DestRect->right -
                     DestRect->left) * sizeof(PIXEL));
+  
+    if (!ScanLine || !ScanLineAhead)
+    {
+      if (ScanLine) ExFreePool(ScanLine);
+      if (ScanLineAhead) ExFreePool(ScanLineAhead);
+      return FALSE;
+    }
 
     DestY = DestRect->top;
     SpanIndex = 0;
index 6c413e2..d7bd909 100644 (file)
@@ -402,6 +402,13 @@ BOOLEAN ScaleRectAvg32(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
   ScanLine = (PIXEL*)ExAllocatePool(PagedPool, (DestRect->right - DestRect->left) * sizeof(PIXEL));
   ScanLineAhead = (PIXEL *)ExAllocatePool(PagedPool, (DestRect->right - DestRect->left) * sizeof(PIXEL));
 
+  if (!ScanLine || !ScanLineAhead)
+    {
+      if (ScanLine) ExFreePool(ScanLine);
+      if (ScanLineAhead) ExFreePool(ScanLineAhead);
+      return FALSE;
+    }
+
   DestY = DestRect->top;
   SpanIndex = 0;
   while (NumPixels-- > 0) {
index 8d22d17..2a79bff 100644 (file)
@@ -387,6 +387,13 @@ BOOLEAN ScaleRectAvg8(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
   ScanLine = (PIXEL*)ExAllocatePool(PagedPool, (DestRect->right - DestRect->left) * sizeof(PIXEL));
   ScanLineAhead = (PIXEL *)ExAllocatePool(PagedPool, (DestRect->right - DestRect->left) * sizeof(PIXEL));
 
+  if (!ScanLine || !ScanLineAhead)
+    {
+      if (ScanLine) ExFreePool(ScanLine);
+      if (ScanLineAhead) ExFreePool(ScanLineAhead);
+      return FALSE;
+    }
+
   DestY = DestRect->top;
   SpanIndex = 0;
   while (NumPixels-- > 0) {
index b07294b..10f144c 100644 (file)
@@ -558,8 +558,8 @@ IntPrepareDriver()
       if (PrimarySurface.pEDDgpl)
       {
           RtlZeroMemory( PrimarySurface.pEDDgpl ,sizeof(EDD_DIRECTDRAW_GLOBAL));
+          ret = TRUE;
       }
-      ret = TRUE;
       goto cleanup;
    }
 
@@ -963,6 +963,11 @@ IntGdiCreateDisplayDC(HDEV hDev, ULONG DcType, BOOL EmptyDC)
   { // This is a cheesy way to do this.
       PDC dc = DC_LockDc ( hDC );
       defaultDCstate = ExAllocatePoolWithTag(PagedPool, sizeof(DC), TAG_DC);
+      if (!defaultDCstate)
+      {
+          DC_UnlockDc( dc );
+          return NULL;
+      }
       RtlZeroMemory(defaultDCstate, sizeof(DC));
       IntGdiCopyToSaveState(dc, defaultDCstate);
       DC_UnlockDc( dc );