Markus Stockhausen : gdi32: Check for NULL pointer in GdiAlphaBlend.

Alexandre Julliard julliard at winehq.org
Fri Sep 18 13:37:31 CDT 2009


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

Author: Markus Stockhausen <markus.stockhausen at collogia.de>
Date:   Fri Sep 18 13:42:11 2009 +0200

gdi32: Check for NULL pointer in GdiAlphaBlend.

---

 dlls/gdi32/bitblt.c       |   10 ++++++----
 dlls/gdi32/tests/bitmap.c |    4 ++++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/dlls/gdi32/bitblt.c b/dlls/gdi32/bitblt.c
index 4270f51..46c7f6f 100644
--- a/dlls/gdi32/bitblt.c
+++ b/dlls/gdi32/bitblt.c
@@ -518,9 +518,11 @@ BOOL WINAPI GdiAlphaBlend(HDC hdcDst, int xDst, int yDst, int widthDst, int heig
     DC *dcDst, *dcSrc;
 
     dcSrc = get_dc_ptr( hdcSrc );
+    if (!dcSrc) return FALSE;
+
     if ((dcDst = get_dc_ptr( hdcDst )))
     {
-        if (dcSrc) update_dc( dcSrc );
+        update_dc( dcSrc );
         update_dc( dcDst );
         TRACE("%p %d,%d %dx%d -> %p %d,%d %dx%d op=%02x flags=%02x srcconstalpha=%02x alphafmt=%02x\n",
               hdcSrc, xSrc, ySrc, widthSrc, heightSrc,
@@ -529,11 +531,11 @@ BOOL WINAPI GdiAlphaBlend(HDC hdcDst, int xDst, int yDst, int widthDst, int heig
               blendFunction.SourceConstantAlpha, blendFunction.AlphaFormat);
         if (dcDst->funcs->pAlphaBlend)
             ret = dcDst->funcs->pAlphaBlend( dcDst->physDev, xDst, yDst, widthDst, heightDst,
-                                             dcSrc ? dcSrc->physDev : NULL,
-                                             xSrc, ySrc, widthSrc, heightSrc, blendFunction );
+                                             dcSrc->physDev, xSrc, ySrc, widthSrc, heightSrc,
+                                             blendFunction );
         release_dc_ptr( dcDst );
     }
-    if (dcSrc) release_dc_ptr( dcSrc );
+    release_dc_ptr( dcSrc );
     return ret;
 }
 
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c
index 8666da2..261f6c2 100644
--- a/dlls/gdi32/tests/bitmap.c
+++ b/dlls/gdi32/tests/bitmap.c
@@ -2393,6 +2393,10 @@ static void test_GdiAlphaBlend(void)
     expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -1, 0, 30, 30, blend), TRUE, BOOL, "%d");
     expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 30, 30, blend), TRUE, BOOL, "%d");
 
+    SetLastError(0xdeadbeef);
+    expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, NULL, 0, 0, 20, 20, blend), FALSE, BOOL, "%d");
+    expect_eq(GetLastError(), 0xdeadbeef, int, "%d");
+
     SelectObject(hdcDst, oldDst);
     SelectObject(hdcSrc, oldSrc);
     DeleteObject(bmpSrc);




More information about the wine-cvs mailing list