Jiajin Cui : gdiplus: Fix crash if failed to create bitmap.

Alexandre Julliard julliard at winehq.org
Mon Jul 20 15:30:09 CDT 2020


Module: wine
Branch: master
Commit: f992bc77c87889c37cbd80aced707e6d1a537c8c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f992bc77c87889c37cbd80aced707e6d1a537c8c

Author: Jiajin Cui <cuijiajin at uniontech.com>
Date:   Fri Jul 17 17:34:09 2020 +0800

gdiplus: Fix crash if failed to create bitmap.

Signed-off-by: Jiajin Cui <cuijiajin at uniontech.com>
Signed-off-by: Esme Povirk <esme at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdiplus/graphics.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 5194719fd6..1307bdc1ef 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -459,6 +459,9 @@ static GpStatus alpha_blend_hdc_pixels(GpGraphics *graphics, INT dst_x, INT dst_
     hbitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS,
         (void**)&temp_bits, NULL, 0);
 
+    if(!hbitmap || !temp_bits)
+        goto done;
+
     if ((GetDeviceCaps(graphics->hdc, TECHNOLOGY) == DT_RASPRINTER &&
          GetDeviceCaps(graphics->hdc, SHADEBLENDCAPS) == SB_NONE) ||
             fmt & PixelFormatPAlpha)
@@ -470,9 +473,12 @@ static GpStatus alpha_blend_hdc_pixels(GpGraphics *graphics, INT dst_x, INT dst_
     SelectObject(hdc, hbitmap);
     gdi_alpha_blend(graphics, dst_x, dst_y, src_width, src_height,
                     hdc, 0, 0, src_width, src_height);
-    DeleteDC(hdc);
+
     DeleteObject(hbitmap);
 
+done:
+    DeleteDC(hdc);
+
     return Ok;
 }
 




More information about the wine-cvs mailing list