>From 90deca5f0a196e66dca98e1d30a6db1ee753b102 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Tue, 6 Sep 2011 21:29:32 +1000
Subject: [PATCH] Return error on invalid parameters
To: wine-patches <wine-patches@winehq.org>

---
 dlls/uxtheme/system.c       |   11 +++++++++++
 dlls/uxtheme/tests/system.c |   14 +++++---------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/dlls/uxtheme/system.c b/dlls/uxtheme/system.c
index 6ee1dac..af11a98 100644
--- a/dlls/uxtheme/system.c
+++ b/dlls/uxtheme/system.c
@@ -689,6 +689,13 @@ HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
 HTHEME WINAPI GetWindowTheme(HWND hwnd)
 {
     TRACE("(%p)\n", hwnd);
+
+    if(!hwnd)
+    {
+        SetLastError(E_HANDLE);
+        return NULL;
+    }
+
     return GetPropW(hwnd, (LPCWSTR)MAKEINTATOM(atWindowTheme));
 }
 
@@ -703,6 +710,10 @@ HRESULT WINAPI SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName,
     HRESULT hr;
     TRACE("(%p,%s,%s)\n", hwnd, debugstr_w(pszSubAppName),
           debugstr_w(pszSubIdList));
+
+    if(!hwnd)
+        return E_HANDLE;
+
     hr = UXTHEME_SetWindowProperty(hwnd, atSubAppName, pszSubAppName);
     if(SUCCEEDED(hr))
         hr = UXTHEME_SetWindowProperty(hwnd, atSubIdList, pszSubIdList);
diff --git a/dlls/uxtheme/tests/system.c b/dlls/uxtheme/tests/system.c
index 8dd413b..974654f 100644
--- a/dlls/uxtheme/tests/system.c
+++ b/dlls/uxtheme/tests/system.c
@@ -117,8 +117,7 @@ static void test_GetWindowTheme(void)
     SetLastError(0xdeadbeef);
     hTheme = pGetWindowTheme(NULL);
     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
-    todo_wine
-        ok( GetLastError() == E_HANDLE,
+    ok( GetLastError() == E_HANDLE,
             "Expected E_HANDLE, got 0x%08x\n",
             GetLastError());
 
@@ -147,13 +146,10 @@ static void test_SetWindowTheme(void)
 
     SetLastError(0xdeadbeef);
     hRes = pSetWindowTheme(NULL, NULL, NULL);
-    todo_wine
-    {
-        ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08x\n", hRes);
-        ok( GetLastError() == 0xdeadbeef,
-            "Expected 0xdeadbeef, got 0x%08x\n",
-            GetLastError());
-    }
+    ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08x\n", hRes);
+    ok( GetLastError() == 0xdeadbeef,
+        "Expected 0xdeadbeef, got 0x%08x\n",
+        GetLastError());
 
     /* Only do the bare minimum to get a valid hwnd */
     hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
-- 
1.7.4.1

