Paul Vriens : advapi32: Handle to Service Control Manager is checked first.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jul 9 10:24:57 CDT 2007


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

Author: Paul Vriens <paul.vriens.wine at gmail.com>
Date:   Mon Jul  9 10:22:49 2007 +0200

advapi32: Handle to Service Control Manager is checked first.

---

 dlls/advapi32/service.c       |   12 ++++++------
 dlls/advapi32/tests/service.c |    1 -
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/dlls/advapi32/service.c b/dlls/advapi32/service.c
index 731d668..9fc351f 100644
--- a/dlls/advapi32/service.c
+++ b/dlls/advapi32/service.c
@@ -1228,12 +1228,6 @@ SC_HANDLE WINAPI OpenServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName,
 
     TRACE("%p %s %d\n", hSCManager, debugstr_w(lpServiceName), dwDesiredAccess);
 
-    if (!lpServiceName)
-    {
-        SetLastError(ERROR_INVALID_ADDRESS);
-        return NULL;
-    }
-
     hscm = sc_handle_get_handle_data( hSCManager, SC_HTYPE_MANAGER );
     if (!hscm)
     {
@@ -1241,6 +1235,12 @@ SC_HANDLE WINAPI OpenServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName,
         return FALSE;
     }
 
+    if (!lpServiceName)
+    {
+        SetLastError(ERROR_INVALID_ADDRESS);
+        return NULL;
+    }
+
     r = RegOpenKeyExW( hscm->hkey, lpServiceName, 0, KEY_ALL_ACCESS, &hKey );
     if (r!=ERROR_SUCCESS)
     {
diff --git a/dlls/advapi32/tests/service.c b/dlls/advapi32/tests/service.c
index 341423e..b3779f9 100644
--- a/dlls/advapi32/tests/service.c
+++ b/dlls/advapi32/tests/service.c
@@ -93,7 +93,6 @@ static void test_open_svc(void)
     SetLastError(0xdeadbeef);
     svc_handle = OpenServiceA(NULL, NULL, 0);
     ok(!svc_handle, "Expected failure\n");
-    todo_wine
     ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
 
     /* TODO: Add some tests with invalid handles. These produce errors on Windows but crash on Wine */




More information about the wine-cvs mailing list