gdi32: simple test for bad pointer

Louis. Lenders xerox_xerox2000 at yahoo.co.uk
Sun Apr 1 13:06:51 CDT 2007


Skipped content of type multipart/alternative-------------- next part --------------
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c
index 99f2986..adb558a 100644
--- a/dlls/gdi32/tests/bitmap.c
+++ b/dlls/gdi32/tests/bitmap.c
@@ -1700,6 +1700,34 @@ static void test_CreateBitmap(void)
     DeleteObject(bm);
 }
 
+static void test_Badpointer()
+{  
+    int lines;
+    HBITMAP hBitmap;
+    BITMAPINFO bmpInfo;
+
+    HDC hdc = GetDC(0);
+    HDC memdc = CreateCompatibleDC(hdc);
+
+    bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+    bmpInfo.bmiHeader.biWidth = 100;
+    bmpInfo.bmiHeader.biHeight = -100;
+    bmpInfo.bmiHeader.biPlanes = 1;
+    bmpInfo.bmiHeader.biBitCount = 24;
+    bmpInfo.bmiHeader.biCompression = BI_RGB;
+ 
+    hBitmap = CreateDIBitmap(hdc, &bmpInfo.bmiHeader, 0, NULL, &bmpInfo, 0);
+    SelectObject(memdc, hBitmap);
+    /* Pass in a bogus pointer here; GetLastError() on windows shows no error is set) */
+    lines = SetDIBits(hdc, hBitmap, 0, 100, (BYTE*) 0xcafedada, &bmpInfo, 0);
+
+    ok(0 == lines, "expected 0, got %d\n",lines);
+
+    DeleteDC(memdc);
+    DeleteObject(hBitmap);
+
+}
+
 START_TEST(bitmap)
 {
     is_win9x = GetWindowLongPtrW(GetDesktopWindow(), GWLP_WNDPROC) == 0;
@@ -1717,4 +1745,5 @@ START_TEST(bitmap)
     test_GetDIBits();
     test_select_object();
     test_CreateBitmap();
+    test_Badpointer();
 }


More information about the wine-patches mailing list