Author: dgorbachev
Date: Thu May 10 14:13:01 2007
New Revision: 26672
URL:
http://svn.reactos.org/svn/reactos?rev=26672&view=rev
Log:
Fix a bug in ScServiceMainStub(), add more checks.
Modified:
trunk/reactos/dll/win32/advapi32/service/sctrl.c
Modified: trunk/reactos/dll/win32/advapi32/service/sctrl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/service/sctrl.c (original)
+++ trunk/reactos/dll/win32/advapi32/service/sctrl.c Thu May 10 14:13:01 2007
@@ -101,7 +101,7 @@
lpPtr = lpService->Arguments;
while (*lpPtr)
{
- DPRINT("arg: %S\n", *lpPtr);
+ DPRINT("arg: %S\n", lpPtr);
dwLen = wcslen(lpPtr) + 1;
dwArgCount++;
dwLength += dwLen;
@@ -153,9 +153,15 @@
0,
NULL,
NULL);
+ if (AnsiLength == 0)
+ return ERROR_INVALID_PARAMETER; /* ? */
+
AnsiString = HeapAlloc(GetProcessHeap(),
0,
- AnsiLength);
+ AnsiLength + 1);
+ if (AnsiString == NULL)
+ return ERROR_OUTOFMEMORY;
+
WideCharToMultiByte(CP_ACP,
0,
lpService->Arguments,
@@ -165,9 +171,13 @@
NULL,
NULL);
+ AnsiString[AnsiLength] = ANSI_NULL;
+
lpArgVector = HeapAlloc(GetProcessHeap(),
0,
(dwArgCount + 1) * sizeof(LPSTR));
+ if (lpArgVector == NULL)
+ return ERROR_OUTOFMEMORY;
dwArgCount = 0;
Ptr = AnsiString;