Paul Vriens : user32/tests: Prevent writing to not allocated memory.

Alexandre Julliard julliard at winehq.org
Wed May 28 14:45:58 CDT 2008


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

Author: Paul Vriens <paul.vriens.wine at gmail.com>
Date:   Wed May 28 13:54:16 2008 +0200

user32/tests: Prevent writing to not allocated memory.

---

 dlls/user32/tests/cursoricon.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c
index dcac002..e00c45e 100644
--- a/dlls/user32/tests/cursoricon.c
+++ b/dlls/user32/tests/cursoricon.c
@@ -593,10 +593,14 @@ static void test_CreateIcon(void)
     bmpinfo.bmiHeader.biBitCount = 8;
     bmpinfo.bmiHeader.biCompression = BI_RGB;
     hbmColor = CreateDIBSection( hdc, &bmpinfo, DIB_RGB_COLORS, &bits, NULL, 0 );
-    memset( bits, 0x55, 32 * 32 * bmpinfo.bmiHeader.biBitCount / 8 );
+    ok(hbmColor != NULL, "Expected a handle to the DIB\n");
+    if (bits)
+        memset( bits, 0x55, 32 * 32 * bmpinfo.bmiHeader.biBitCount / 8 );
     bmpinfo.bmiHeader.biBitCount = 1;
     hbmMask = CreateDIBSection( hdc, &bmpinfo, DIB_RGB_COLORS, &bits, NULL, 0 );
-    memset( bits, 0x55, 32 * 32 * bmpinfo.bmiHeader.biBitCount / 8 );
+    ok(hbmMask != NULL, "Expected a handle to the DIB\n");
+    if (bits)
+        memset( bits, 0x55, 32 * 32 * bmpinfo.bmiHeader.biBitCount / 8 );
 
     info.fIcon = TRUE;
     info.xHotspot = 8;
@@ -612,7 +616,9 @@ static void test_CreateIcon(void)
 
     bmpinfo.bmiHeader.biBitCount = 16;
     hbmColor = CreateDIBSection( hdc, &bmpinfo, DIB_RGB_COLORS, &bits, NULL, 0 );
-    memset( bits, 0x55, 32 * 32 * bmpinfo.bmiHeader.biBitCount / 8 );
+    ok(hbmColor != NULL, "Expected a handle to the DIB\n");
+    if (bits)
+        memset( bits, 0x55, 32 * 32 * bmpinfo.bmiHeader.biBitCount / 8 );
 
     info.fIcon = TRUE;
     info.xHotspot = 8;
@@ -628,7 +634,9 @@ static void test_CreateIcon(void)
 
     bmpinfo.bmiHeader.biBitCount = 32;
     hbmColor = CreateDIBSection( hdc, &bmpinfo, DIB_RGB_COLORS, &bits, NULL, 0 );
-    memset( bits, 0x55, 32 * 32 * bmpinfo.bmiHeader.biBitCount / 8 );
+    ok(hbmColor != NULL, "Expected a handle to the DIB\n");
+    if (bits)
+        memset( bits, 0x55, 32 * 32 * bmpinfo.bmiHeader.biBitCount / 8 );
 
     info.fIcon = TRUE;
     info.xHotspot = 8;




More information about the wine-cvs mailing list