Author: dchapyshev Date: Sat Jan 10 11:50:03 2009 New Revision: 38682
URL: http://svn.reactos.org/svn/reactos?rev=38682&view=rev Log: - Fix GetEnvironmentVariableW. This fixed also 4 wine tests for OpenFile and SearchPathA/W
Modified: trunk/reactos/dll/win32/kernel32/misc/env.c
Modified: trunk/reactos/dll/win32/kernel32/misc/env.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/env... ============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/env.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/env.c [iso-8859-1] Sat Jan 10 11:50:03 2009 @@ -139,7 +139,7 @@ lpName);
VarValue.Length = 0; - VarValue.MaximumLength = (USHORT)(nSize != 0 ? (nSize - 1) * sizeof(WCHAR) : 0); + VarValue.MaximumLength = (USHORT) (nSize ? nSize - 1 : 0) * sizeof(WCHAR); VarValue.Buffer = lpBuffer;
Status = RtlQueryEnvironmentVariable_U (NULL, @@ -147,13 +147,13 @@ &VarValue); if (!NT_SUCCESS(Status)) { - SetLastErrorByStatus (Status); if (Status == STATUS_BUFFER_TOO_SMALL) { return (VarValue.Length / sizeof(WCHAR)) + 1; } else { + SetLastErrorByStatus (Status); return 0; } } @@ -162,7 +162,7 @@ { /* make sure the string is NULL-terminated! RtlQueryEnvironmentVariable_U only terminates it if MaximumLength < Length */ - VarValue.Buffer[VarValue.Length / sizeof(WCHAR)] = L'\0'; + lpBuffer[VarValue.Length / sizeof(WCHAR)] = L'\0'; }
return (VarValue.Length / sizeof(WCHAR));