From ce552d4451ffecbb3c61eeb3982541a56872bae3 Mon Sep 17 00:00:00 2001
From: Lei Zhang <thestig@google.com>
Date: Fri, 18 Jul 2008 15:28:44 -0700
Subject: [PATCH] gdi32: CreateDIBitmap should check for SetDIBits failure.

---
 dlls/gdi32/dib.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index 677cda5eb2c..440857dc243 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -1118,7 +1118,14 @@ HBITMAP WINAPI CreateDIBitmap( HDC hdc, const BITMAPINFOHEADER *header,
 
     if (handle)
     {
-        if (init == CBM_INIT) SetDIBits( hdc, handle, 0, height, bits, data, coloruse );
+        if (init == CBM_INIT)
+        {
+            if (SetDIBits( hdc, handle, 0, height, bits, data, coloruse ) == 0)
+            {
+                DeleteObject( handle );
+                handle = 0;
+            }
+        }
 
         else if (hdc && ((dc = get_dc_ptr( hdc )) != NULL) )
         {
-- 
GitLab