user32: Add a simple DrawState test, make it pass under Wine
Dmitry Timoshkov
dmitry at codeweavers.com
Thu Jan 11 04:06:19 CST 2007
Hello,
this patch fixes a crash reported on wine-license list today.
Changelog:
user32: Add a simple DrawState test, make it pass under Wine.
---
dlls/user32/tests/text.c | 43 +++++++++++++++++++++++++++++++++++++++++++
dlls/user32/uitools.c | 2 ++
2 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/dlls/user32/tests/text.c b/dlls/user32/tests/text.c
index 76d4184..01bd306 100644
--- a/dlls/user32/tests/text.c
+++ b/dlls/user32/tests/text.c
@@ -2,6 +2,7 @@
* DrawText tests
*
* Copyright (c) 2004 Zach Gorman
+ * Copyright 2007 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -243,11 +244,53 @@ static void test_TabbedText(void)
}
}
+ ReleaseDC( hwnd, hdc );
+ DestroyWindow( hwnd );
+}
+
+static void test_DrawState(void)
+{
+ static const char text[] = "Sample text string";
+ HWND hwnd;
+ HDC hdc;
+ BOOL ret;
+
+ hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
+ 0, 0, 200, 200, 0, 0, 0, NULL);
+ assert(hwnd);
+
+ hdc = GetDC(hwnd);
+ assert(hdc);
+
+ SetLastError(0xdeadbeef);
+ ret = DrawState(hdc, GetStockObject(DKGRAY_BRUSH), NULL, (LPARAM)text, strlen(text),
+ 0, 0, 10, 10, DST_TEXT);
+ ok(ret, "DrawState error %u\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = DrawState(hdc, GetStockObject(DKGRAY_BRUSH), NULL, (LPARAM)text, 0,
+ 0, 0, 10, 10, DST_TEXT);
+ ok(ret, "DrawState error %u\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = DrawState(hdc, GetStockObject(DKGRAY_BRUSH), NULL, 0, strlen(text),
+ 0, 0, 10, 10, DST_TEXT);
+ ok(!ret, "DrawState succeeded\n");
+ ok(GetLastError() == 0xdeadbeef, "not expected error %u\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = DrawState(hdc, GetStockObject(DKGRAY_BRUSH), NULL, 0, 0,
+ 0, 0, 10, 10, DST_TEXT);
+ ok(!ret, "DrawState succeeded\n");
+ ok(GetLastError() == 0xdeadbeef, "not expected error %u\n", GetLastError());
+ ReleaseDC(hwnd, hdc);
+ DestroyWindow(hwnd);
}
START_TEST(text)
{
test_TabbedText();
test_DrawTextCalcRect();
+ test_DrawState();
}
diff --git a/dlls/user32/uitools.c b/dlls/user32/uitools.c
index c504c4c..036379c 100644
--- a/dlls/user32/uitools.c
+++ b/dlls/user32/uitools.c
@@ -1587,6 +1587,8 @@ static BOOL UITOOLS_DrawState(HDC hdc, HBRUSH hbr, DRAWSTATEPROC func, LPARAM lp
if((opcode == DST_TEXT || opcode == DST_PREFIXTEXT) && !len) /* The string is '\0' terminated */
{
+ if (!lp) return FALSE;
+
if(unicode)
len = strlenW((LPWSTR)lp);
else
--
1.4.4.4
More information about the wine-patches
mailing list