mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 17:03:02 +00:00
fixed length calculation of lpDependencies
svn path=/trunk/; revision=19292
This commit is contained in:
parent
d711215962
commit
5333007c97
1 changed files with 23 additions and 9 deletions
|
@ -285,6 +285,9 @@ CreateServiceA(
|
||||||
LPWSTR lpDependenciesW = NULL;
|
LPWSTR lpDependenciesW = NULL;
|
||||||
LPWSTR lpServiceStartNameW = NULL;
|
LPWSTR lpServiceStartNameW = NULL;
|
||||||
LPWSTR lpPasswordW = NULL;
|
LPWSTR lpPasswordW = NULL;
|
||||||
|
DWORD dwDependenciesLength = 0;
|
||||||
|
DWORD dwLength;
|
||||||
|
LPSTR lpStr;
|
||||||
|
|
||||||
int len = MultiByteToWideChar(CP_ACP, 0, lpServiceName, -1, NULL, 0);
|
int len = MultiByteToWideChar(CP_ACP, 0, lpServiceName, -1, NULL, 0);
|
||||||
lpServiceNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
lpServiceNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
||||||
|
@ -322,8 +325,19 @@ CreateServiceA(
|
||||||
}
|
}
|
||||||
MultiByteToWideChar(CP_ACP, 0, lpLoadOrderGroup, -1, lpLoadOrderGroupW, len);
|
MultiByteToWideChar(CP_ACP, 0, lpLoadOrderGroup, -1, lpLoadOrderGroupW, len);
|
||||||
|
|
||||||
len = MultiByteToWideChar(CP_ACP, 0, lpDependencies, -1, NULL, 0);
|
if (lpDependencies != NULL)
|
||||||
lpDependenciesW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
{
|
||||||
|
lpStr = (LPSTR)lpDependencies;
|
||||||
|
while (*lpStr)
|
||||||
|
{
|
||||||
|
dwLength = strlen(lpStr) + 1;
|
||||||
|
dwDependenciesLength += dwLength;
|
||||||
|
lpStr = lpStr + dwLength;
|
||||||
|
}
|
||||||
|
dwDependenciesLength++;
|
||||||
|
}
|
||||||
|
|
||||||
|
lpDependenciesW = HeapAlloc(GetProcessHeap(), 0, dwDependenciesLength * sizeof(WCHAR));
|
||||||
if (!lpDependenciesW)
|
if (!lpDependenciesW)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
@ -365,13 +379,13 @@ CreateServiceA(
|
||||||
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (!lpServiceNameW) HeapFree(GetProcessHeap(), 0, lpServiceNameW);
|
HeapFree(GetProcessHeap(), 0, lpServiceNameW);
|
||||||
if (!lpDisplayNameW) HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
|
HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
|
||||||
if (!lpBinaryPathNameW) HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
|
HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
|
||||||
if (!lpLoadOrderGroupW) HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW);
|
HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW);
|
||||||
if (!lpDependenciesW) HeapFree(GetProcessHeap(), 0, lpDependenciesW);
|
HeapFree(GetProcessHeap(), 0, lpDependenciesW);
|
||||||
if (!lpServiceStartNameW) HeapFree(GetProcessHeap(), 0, lpServiceStartNameW);
|
HeapFree(GetProcessHeap(), 0, lpServiceStartNameW);
|
||||||
if (!lpPasswordW) HeapFree(GetProcessHeap(), 0, lpPasswordW);
|
HeapFree(GetProcessHeap(), 0, lpPasswordW);
|
||||||
|
|
||||||
return RetVal;
|
return RetVal;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue