Author: khornicek
Date: Wed Nov 2 20:10:02 2011
New Revision: 54282
URL:
http://svn.reactos.org/svn/reactos?rev=54282&view=rev
Log:
[KERNEL32]
Fix GetEnvironmentStringsA/W.
See issue #6633 for more details.
Modified:
trunk/reactos/dll/win32/kernel32/client/environ.c
Modified: trunk/reactos/dll/win32/kernel32/client/environ.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/environ.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/environ.c [iso-8859-1] Wed Nov 2 20:10:02
2011
@@ -294,18 +294,18 @@
do
{
- p += wcslen(Environment) + 1;
+ p += wcslen(p) + 1;
} while (*p);
- Length = p - Environment + sizeof(UNICODE_NULL);
-
- Status = RtlUnicodeToMultiByteSize(&Size, Environment, Length);
+ Length = p - Environment + 1;
+
+ Status = RtlUnicodeToMultiByteSize(&Size, Environment, Length * sizeof(WCHAR));
if (NT_SUCCESS(Status))
{
Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Size);
if (Buffer)
{
- Status = RtlUnicodeToOemN(Buffer, Size, 0, Environment, Length);
+ Status = RtlUnicodeToOemN(Buffer, Size, 0, Environment, Length *
sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
@@ -344,15 +344,15 @@
do
{
- p += wcslen(Environment) + 1;
+ p += wcslen(p) + 1;
} while (*p);
- Length = p - Environment + sizeof(UNICODE_NULL);
-
- p = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length);
+ Length = p - Environment + 1;
+
+ p = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length * sizeof(WCHAR));
if (p)
{
- RtlCopyMemory(p, Environment, Length);
+ RtlCopyMemory(p, Environment, Length * sizeof(WCHAR));
}
else
{