Author: greatlrd
Date: Sat Jul 1 02:07:54 2006
New Revision: 22732
URL:
http://svn.reactos.org/svn/reactos?rev=22732&view=rev
Log:
CreateServiceA
1. Do not try todo HeapFree when pointer is NULL in cleanup:
2. Remove goto cleanup code
3. Rewrote the code so it does not need goto
Modified:
trunk/reactos/dll/win32/advapi32/service/scm.c
Modified: trunk/reactos/dll/win32/advapi32/service/scm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/service/scm.c (original)
+++ trunk/reactos/dll/win32/advapi32/service/scm.c Sat Jul 1 02:07:54 2006
@@ -442,7 +442,8 @@
if (!lpServiceNameW)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+
+ return NULL;
}
MultiByteToWideChar(CP_ACP, 0, lpServiceName, -1, lpServiceNameW, len);
}
@@ -454,7 +455,9 @@
if (!lpDisplayNameW)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+
+ HeapFree(GetProcessHeap(), 0, lpServiceNameW);
+ return NULL;
}
MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, lpDisplayNameW, len);
}
@@ -466,7 +469,10 @@
if (!lpBinaryPathNameW)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+
+ HeapFree(GetProcessHeap(), 0, lpServiceNameW);
+ HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
+ return NULL;
}
MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, lpBinaryPathNameW, len);
}
@@ -478,7 +484,11 @@
if (!lpLoadOrderGroupW)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+
+ HeapFree(GetProcessHeap(), 0, lpServiceNameW);
+ HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
+ HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
+ return NULL;
}
MultiByteToWideChar(CP_ACP, 0, lpLoadOrderGroup, -1, lpLoadOrderGroupW, len);
}
@@ -498,7 +508,12 @@
if (!lpDependenciesW)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+
+ HeapFree(GetProcessHeap(), 0, lpServiceNameW);
+ HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
+ HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
+ HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW);
+ return NULL;
}
MultiByteToWideChar(CP_ACP, 0, lpDependencies, -1, lpDependenciesW,
dwDependenciesLength);
}
@@ -510,7 +525,13 @@
if (!lpServiceStartNameW)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+
+ HeapFree(GetProcessHeap(), 0, lpServiceNameW);
+ HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
+ HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
+ HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW);
+ HeapFree(GetProcessHeap(), 0, lpDependenciesW);
+ return NULL;
}
MultiByteToWideChar(CP_ACP, 0, lpServiceStartName, -1, lpServiceStartNameW,
len);
}
@@ -522,7 +543,14 @@
if (!lpPasswordW)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+
+ HeapFree(GetProcessHeap(), 0, lpServiceNameW);
+ HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
+ HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
+ HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW);
+ HeapFree(GetProcessHeap(), 0, lpDependenciesW);
+ HeapFree(GetProcessHeap(), 0, lpServiceStartNameW);
+ return NULL;
}
MultiByteToWideChar(CP_ACP, 0, lpPassword, -1, lpPasswordW, len);
}
@@ -541,7 +569,7 @@
lpServiceStartNameW,
lpPasswordW);
-cleanup:
+
HeapFree(GetProcessHeap(), 0, lpServiceNameW);
HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);