From cc269f9cb477bb258f3ea8a512f4ae74ab4ddcdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 8 Feb 2014 22:22:21 +0000 Subject: [PATCH] [KERNEL32] 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 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/reactos/dll/win32/kernel32/client/proc.c b/reactos/dll/win32/kernel32/client/proc.c index b6eadb09327..6c44e99069a 100644 --- a/reactos/dll/win32/kernel32/client/proc.c +++ b/reactos/dll/win32/kernel32/client/proc.c @@ -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;