Author: rharabien
Date: Sun Oct 9 09:55:40 2011
New Revision: 54061
URL:
http://svn.reactos.org/svn/reactos?rev=54061&view=rev
Log:
[RTL] - Make sure RtlInitUnicodeString(Ex) don't set odd length. Fixes ntdll:rtlstr
winetest.
Modified:
trunk/reactos/lib/rtl/unicode.c
Modified: trunk/reactos/lib/rtl/unicode.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/unicode.c?rev=5406…
==============================================================================
--- trunk/reactos/lib/rtl/unicode.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/unicode.c [iso-8859-1] Sun Oct 9 09:55:40 2011
@@ -584,11 +584,12 @@
IN PCWSTR SourceString)
{
SIZE_T Size;
+ CONST SIZE_T MaxSize = (MAXUSHORT & ~1) - sizeof(WCHAR); // an even number
if (SourceString)
{
Size = wcslen(SourceString) * sizeof(WCHAR);
- if (Size > (MAXUSHORT - sizeof(WCHAR))) Size = MAXUSHORT - sizeof(WCHAR);
+ if (Size > MaxSize) Size = MaxSize;
DestinationString->Length = (USHORT)Size;
DestinationString->MaximumLength = (USHORT)Size + sizeof(WCHAR);
}
@@ -611,11 +612,12 @@
IN PCWSTR SourceString)
{
SIZE_T Size;
+ CONST SIZE_T MaxSize = (MAXUSHORT & ~1) - sizeof(WCHAR); // an even number
if (SourceString)
{
Size = wcslen(SourceString) * sizeof(WCHAR);
- if (Size > (MAXUSHORT - sizeof(WCHAR))) return STATUS_NAME_TOO_LONG;
+ if (Size > MaxSize) return STATUS_NAME_TOO_LONG;
DestinationString->Length = (USHORT)Size;
DestinationString->MaximumLength = (USHORT)Size + sizeof(WCHAR);
}