https://git.reactos.org/?p=reactos.git;a=commitdiff;h=090ccb3d8e732d9545cf979f5b716c985afaf2d8

commit 090ccb3d8e732d9545cf979f5b716c985afaf2d8
Author:     Timo Kreuzer <[email protected]>
AuthorDate: Sat Jul 23 17:08:12 2022 +0200
Commit:     Timo Kreuzer <[email protected]>
CommitDate: Thu Aug 4 16:15:24 2022 +0200

    [WIN32K] Add missing NULL checks
    
    Also fix an old copy-pasta.
---
 win32ss/gdi/ntgdi/bitmaps.c | 7 ++++++-
 win32ss/gdi/ntgdi/dibobj.c  | 5 +++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/win32ss/gdi/ntgdi/bitmaps.c b/win32ss/gdi/ntgdi/bitmaps.c
index c2f38c55f40..dd7aa4486e1 100644
--- a/win32ss/gdi/ntgdi/bitmaps.c
+++ b/win32ss/gdi/ntgdi/bitmaps.c
@@ -333,6 +333,11 @@ IntCreateCompatibleBitmap(
                           Planes ? Planes : 1,
                           Bpp ? Bpp : dibs.dsBm.bmBitsPixel,
                           NULL);
+            if (Bmp == NULL)
+            {
+                DPRINT1("Failed to allocate a bitmap!\n");
+                return NULL;
+            }
             psurfBmp = SURFACE_ShareLockSurface(Bmp);
             ASSERT(psurfBmp);
 
@@ -342,7 +347,7 @@ IntCreateCompatibleBitmap(
             /* Set flags */
             psurfBmp->flags = API_BITMAP;
             psurfBmp->hdc = NULL; // FIXME:
-            psurf->SurfObj.hdev = (HDEV)Dc->ppdev;
+            psurfBmp->SurfObj.hdev = (HDEV)Dc->ppdev;
             SURFACE_ShareUnlockSurface(psurfBmp);
         }
         else if (Count == sizeof(DIBSECTION))
diff --git a/win32ss/gdi/ntgdi/dibobj.c b/win32ss/gdi/ntgdi/dibobj.c
index 6c6dd53e941..b7bf542446a 100644
--- a/win32ss/gdi/ntgdi/dibobj.c
+++ b/win32ss/gdi/ntgdi/dibobj.c
@@ -69,6 +69,11 @@ CreateDIBPalette(
                                     0,
                                     0,
                                     0);
+        if (ppal == NULL)
+        {
+            DPRINT1("Failed to allocate palette.\n");
+            return NULL;
+        }
 
         /* Check if the BITMAPINFO specifies how many colors to use */
         if ((pbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) &&

Reply via email to