- Fix GetEnvironmentVariableW. This fixed also 4 wine tests for OpenFile and SearchPathA/W

svn path=/trunk/; revision=38682
This commit is contained in:
Dmitry Chapyshev 2009-01-10 17:50:03 +00:00
parent 8dd743f625
commit 9fe45fbb32

View file

@ -139,7 +139,7 @@ GetEnvironmentVariableW (
lpName); lpName);
VarValue.Length = 0; 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; VarValue.Buffer = lpBuffer;
Status = RtlQueryEnvironmentVariable_U (NULL, Status = RtlQueryEnvironmentVariable_U (NULL,
@ -147,13 +147,13 @@ GetEnvironmentVariableW (
&VarValue); &VarValue);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus (Status);
if (Status == STATUS_BUFFER_TOO_SMALL) if (Status == STATUS_BUFFER_TOO_SMALL)
{ {
return (VarValue.Length / sizeof(WCHAR)) + 1; return (VarValue.Length / sizeof(WCHAR)) + 1;
} }
else else
{ {
SetLastErrorByStatus (Status);
return 0; return 0;
} }
} }
@ -162,7 +162,7 @@ GetEnvironmentVariableW (
{ {
/* make sure the string is NULL-terminated! RtlQueryEnvironmentVariable_U /* make sure the string is NULL-terminated! RtlQueryEnvironmentVariable_U
only terminates it if MaximumLength < Length */ 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)); return (VarValue.Length / sizeof(WCHAR));