From 04ca56cb81d2759d87c36a2a1e0c4a5deae58e39 Mon Sep 17 00:00:00 2001 From: Mikolaj Zalewski Date: Tue, 16 Oct 2007 17:49:28 -0700 Subject: [PATCH] ntdll: avoid IS_TEXT_UNICODE_NUL_BYTES for the last byte in the string --- dlls/ntdll/rtlstr.c | 3 +++ dlls/ntdll/tests/rtlstr.c | 2 +- 2 files changed, 4 insertions(+), 1 deletions(-) diff --git a/dlls/ntdll/rtlstr.c b/dlls/ntdll/rtlstr.c index 1b13f12..ecd8523 100644 --- a/dlls/ntdll/rtlstr.c +++ b/dlls/ntdll/rtlstr.c @@ -1610,6 +1610,9 @@ BOOLEAN WINAPI RtlIsTextUnicode( LPCVOID /* 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 65b9b52..e40bd53 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"); -- 1.4.1