[KERNEL32]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 8 Feb 2014 22:22:21 +0000 (22:22 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 8 Feb 2014 22:22:21 +0000 (22:22 +0000)
Fix finding the environment multi-string size (use the same code as in RtlpInitEnvironment instead of using hackish and broken code; the two while() are here because the environment string is a "multi-string", hence a list of strings, each terminated by a NULL char, and the whole multi-string is terminated by two NULL chars (the one of the last string plus an empty string).
Also fix a cast.
This fixes the launch of some programs, and this was triggered by tring to compiling the host-tools of the ReactOS source code with RosBE, on ReactOS.
CORE-7870 #resolve #comment Fixed in revision 62060.

svn path=/trunk/; revision=62060

reactos/dll/win32/kernel32/client/proc.c

index b6eadb0..6c44e99 100644 (file)
@@ -673,9 +673,8 @@ BasePushProcessParameters(IN ULONG ParameterFlags,
     if (lpEnvironment)
     {
         /* Find the environment size */
-        while ((ScanChar[0]) || (ScanChar[1])) ++ScanChar;
-        ScanChar += (2 * sizeof(UNICODE_NULL));
-        EnviroSize = (ULONG_PTR)ScanChar - (ULONG_PTR)lpEnvironment;
+        while (*ScanChar++) while (*ScanChar++);
+        EnviroSize = (ULONG)((ULONG_PTR)ScanChar - (ULONG_PTR)lpEnvironment);
 
         /* Allocate and Initialize new Environment Block */
         Size = EnviroSize;