[ADVAPI32]
authorEric Kohl <eric.kohl@reactos.org>
Sat, 16 Jul 2016 16:18:17 +0000 (16:18 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 16 Jul 2016 16:18:17 +0000 (16:18 +0000)
Remove unneeded NULL checks at CreateServiceA/W and ChangeServiceConfigW/A().
Patch by Victor Martinez Calvo.
CORE-11610 #resolve #comment Thanks a lot!

svn path=/trunk/; revision=71953

reactos/dll/win32/advapi32/service/scm.c

index 198eb98..1449e4e 100644 (file)
@@ -326,7 +326,7 @@ ChangeServiceConfigA(SC_HANDLE hService,
 
         /* FIXME: Encrypt the password */
         lpEncryptedPassword = (LPBYTE)lpPasswordW;
 
         /* FIXME: Encrypt the password */
         lpEncryptedPassword = (LPBYTE)lpPasswordW;
-        dwPasswordLength = (DWORD)(lpPasswordW ? (wcslen(lpPasswordW) + 1) * sizeof(WCHAR) : 0);
+        dwPasswordLength = (wcslen(lpPasswordW) + 1) * sizeof(WCHAR);
     }
 
     RpcTryExcept
     }
 
     RpcTryExcept
@@ -407,9 +407,12 @@ ChangeServiceConfigW(SC_HANDLE hService,
         dwDependenciesLength *= sizeof(WCHAR);
     }
 
         dwDependenciesLength *= sizeof(WCHAR);
     }
 
-    /* FIXME: Encrypt the password */
-    lpEncryptedPassword = (LPBYTE)lpPassword;
-    dwPasswordLength = (lpPassword ? (wcslen(lpPassword) + 1) * sizeof(WCHAR) : 0);
+    if (lpPassword != NULL)
+    {
+        /* FIXME: Encrypt the password */
+        lpEncryptedPassword = (LPBYTE)lpPassword;
+        dwPasswordLength = (wcslen(lpPassword) + 1) * sizeof(WCHAR);
+    }
 
     RpcTryExcept
     {
 
     RpcTryExcept
     {
@@ -619,7 +622,7 @@ CreateServiceA(SC_HANDLE hSCManager,
 
         /* FIXME: Encrypt the password */
         lpEncryptedPassword = (LPBYTE)lpPasswordW;
 
         /* FIXME: Encrypt the password */
         lpEncryptedPassword = (LPBYTE)lpPasswordW;
-        dwPasswordLength = (DWORD)(lpPasswordW ? (wcslen(lpPasswordW) + 1) * sizeof(WCHAR) : 0);
+        dwPasswordLength = (wcslen(lpPasswordW) + 1) * sizeof(WCHAR);
     }
 
     RpcTryExcept
     }
 
     RpcTryExcept
@@ -714,9 +717,12 @@ CreateServiceW(SC_HANDLE hSCManager,
         dwDependenciesLength *= sizeof(WCHAR);
     }
 
         dwDependenciesLength *= sizeof(WCHAR);
     }
 
-    /* FIXME: Encrypt the password */
-    lpEncryptedPassword = (LPBYTE)lpPassword;
-    dwPasswordLength = (DWORD)(lpPassword ? (wcslen(lpPassword) + 1) * sizeof(WCHAR) : 0);
+    if (lpPassword != NULL)
+    {
+        /* FIXME: Encrypt the password */
+        lpEncryptedPassword = (LPBYTE)lpPassword;
+        dwPasswordLength = (wcslen(lpPassword) + 1) * sizeof(WCHAR);
+    }
 
     RpcTryExcept
     {
 
     RpcTryExcept
     {