Author: greatlrd
Date: Sat Jul 1 02:26:19 2006
New Revision: 22733
URL:
http://svn.reactos.org/svn/reactos?rev=22733&view=rev
Log:
1. revert my last changes to this file
2. Did solv the heapfree null check with if statement
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:26:19 2006
@@ -443,7 +443,7 @@
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
+ goto cleanup;
}
MultiByteToWideChar(CP_ACP, 0, lpServiceName, -1, lpServiceNameW, len);
}
@@ -456,8 +456,7 @@
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- HeapFree(GetProcessHeap(), 0, lpServiceNameW);
- return NULL;
+ goto cleanup;
}
MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, lpDisplayNameW, len);
}
@@ -470,9 +469,7 @@
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- HeapFree(GetProcessHeap(), 0, lpServiceNameW);
- HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
- return NULL;
+ goto cleanup;
}
MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, lpBinaryPathNameW, len);
}
@@ -485,10 +482,7 @@
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- HeapFree(GetProcessHeap(), 0, lpServiceNameW);
- HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
- HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
- return NULL;
+ goto cleanup;
}
MultiByteToWideChar(CP_ACP, 0, lpLoadOrderGroup, -1, lpLoadOrderGroupW, len);
}
@@ -509,11 +503,7 @@
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- HeapFree(GetProcessHeap(), 0, lpServiceNameW);
- HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
- HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
- HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW);
- return NULL;
+ goto cleanup;
}
MultiByteToWideChar(CP_ACP, 0, lpDependencies, -1, lpDependenciesW,
dwDependenciesLength);
}
@@ -526,12 +516,7 @@
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- HeapFree(GetProcessHeap(), 0, lpServiceNameW);
- HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
- HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
- HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW);
- HeapFree(GetProcessHeap(), 0, lpDependenciesW);
- return NULL;
+ goto cleanup;
}
MultiByteToWideChar(CP_ACP, 0, lpServiceStartName, -1, lpServiceStartNameW,
len);
}
@@ -544,13 +529,7 @@
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- 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;
+ goto cleanup;
}
MultiByteToWideChar(CP_ACP, 0, lpPassword, -1, lpPasswordW, len);
}
@@ -569,14 +548,35 @@
lpServiceStartNameW,
lpPasswordW);
-
- HeapFree(GetProcessHeap(), 0, lpServiceNameW);
- HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
- HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
- HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW);
- HeapFree(GetProcessHeap(), 0, lpDependenciesW);
- HeapFree(GetProcessHeap(), 0, lpServiceStartNameW);
- HeapFree(GetProcessHeap(), 0, lpPasswordW);
+cleanup:
+ if (lpServiceNameW !=NULL)
+ {
+ HeapFree(GetProcessHeap(), 0, lpServiceNameW);
+ }
+ if (lpDisplayNameW != NULL)
+ {
+ HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
+ }
+ if (lpBinaryPathNameW != NULL)
+ {
+ HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
+ }
+ if (lpLoadOrderGroupW != NULL)
+ {
+ HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW);
+ }
+ if (lpDependenciesW != NULL)
+ {
+ HeapFree(GetProcessHeap(), 0, lpDependenciesW);
+ }
+ if (lpServiceStartNameW != NULL)
+ {
+ HeapFree(GetProcessHeap(), 0, lpServiceStartNameW);
+ }
+ if (lpPasswordW != NULL)
+ {
+ HeapFree(GetProcessHeap(), 0, lpPasswordW);
+ }
return RetVal;
}