[ros-diffs] [pschweitzer] 54459: [KERNEL32] Properly fix GetEnvironmentVariableW and set error in case of RtlInitUnicodeStringEx failure
pschweitzer at svn.reactos.org
pschweitzer at svn.reactos.org
Sun Nov 20 17:00:40 UTC 2011
Author: pschweitzer
Date: Sun Nov 20 17:00:39 2011
New Revision: 54459
URL: http://svn.reactos.org/svn/reactos?rev=54459&view=rev
Log:
[KERNEL32]
Properly fix GetEnvironmentVariableW and set error in case of RtlInitUnicodeStringEx failure
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/environ.c?rev=54459&r1=54458&r2=54459&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/environ.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/environ.c [iso-8859-1] Sun Nov 20 17:00:39 2011
@@ -181,24 +181,28 @@
{
UniSize = UNICODE_STRING_MAX_BYTES - sizeof(UNICODE_NULL);
}
+
+ Status = RtlInitUnicodeStringEx(&VarName, lpName);
+ if (!NT_SUCCESS(Status))
+ {
+ BaseSetLastNTError(Status);
+ return 0;
+ }
RtlInitEmptyUnicodeString(&VarValue, lpBuffer, UniSize);
- Status = RtlInitUnicodeStringEx(&VarName, lpName);
- if (NT_SUCCESS(Status))
- {
- Status = RtlQueryEnvironmentVariable_U(NULL, &VarName, &VarValue);
- if (!NT_SUCCESS(Status))
- {
- if (Status == STATUS_BUFFER_TOO_SMALL)
- {
- return (VarValue.Length / sizeof(WCHAR)) + sizeof(ANSI_NULL);
- }
- BaseSetLastNTError (Status);
- return 0;
- }
-
- lpBuffer[VarValue.Length / sizeof(WCHAR)] = UNICODE_NULL;
- }
+
+ Status = RtlQueryEnvironmentVariable_U(NULL, &VarName, &VarValue);
+ if (!NT_SUCCESS(Status))
+ {
+ if (Status == STATUS_BUFFER_TOO_SMALL)
+ {
+ return (VarValue.Length / sizeof(WCHAR)) + sizeof(ANSI_NULL);
+ }
+ BaseSetLastNTError (Status);
+ return 0;
+ }
+
+ lpBuffer[VarValue.Length / sizeof(WCHAR)] = UNICODE_NULL;
return (VarValue.Length / sizeof(WCHAR));
}
More information about the Ros-diffs
mailing list