From 370b881fcda8b7b8ef8fe2cfbe99c824882fd104 Mon Sep 17 00:00:00 2001 From: Mikolaj Zalewski Date: Tue, 16 Oct 2007 17:49:28 -0700 Subject: [PATCH] ntdll: Avoid setting IS_TEXT_UNICODE_NUL_BYTES for the last byte of an ANSI string. --- dlls/ntdll/rtlstr.c | 3 +++ dlls/ntdll/tests/rtlstr.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/rtlstr.c b/dlls/ntdll/rtlstr.c index 1b13f127156..ecd8523365c 100644 --- a/dlls/ntdll/rtlstr.c +++ b/dlls/ntdll/rtlstr.c @@ -1610,6 +1610,9 @@ BOOLEAN WINAPI RtlIsTextUnicode( LPCVOID buf, INT len, INT *pf ) /* Check for an odd length ... pass if even. */ if (len & 1) out_flags |= IS_TEXT_UNICODE_ODD_LENGTH; + if (((char *)buf)[len - 1] == 0) + len--; /* Windows seems to do something like that to avoid e.g. false IS_TEXT_UNICODE_NULL_BYTES */ + len /= sizeof(WCHAR); /* Windows only checks the first 256 characters */ if (len > 256) len = 256; diff --git a/dlls/ntdll/tests/rtlstr.c b/dlls/ntdll/tests/rtlstr.c index 65b9b5217cd..e40bd53e03c 100644 --- a/dlls/ntdll/tests/rtlstr.c +++ b/dlls/ntdll/tests/rtlstr.c @@ -1677,7 +1677,7 @@ static void test_RtlIsTextUnicode(void) int flags; int i; - todo_wine ok(!pRtlIsTextUnicode(ascii, sizeof(ascii), NULL), "ASCII text detected as Unicode\n"); + ok(!pRtlIsTextUnicode(ascii, sizeof(ascii), NULL), "ASCII text detected as Unicode\n"); ok(pRtlIsTextUnicode(unicode, sizeof(unicode), NULL), "Text should be Unicode\n"); ok(!pRtlIsTextUnicode(unicode, sizeof(unicode) - 1, NULL), "Text should be Unicode\n");