Mikolaj Zalewski : ntdll: Avoid setting IS_TEXT_UNICODE_NUL_BYTES for the last byte of an ANSI string .

Alexandre Julliard julliard at winehq.org
Wed Oct 17 09:05:26 CDT 2007


Module: wine
Branch: master
Commit: 370b881fcda8b7b8ef8fe2cfbe99c824882fd104
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=370b881fcda8b7b8ef8fe2cfbe99c824882fd104

Author: Mikolaj Zalewski <mikolajz at google.com>
Date:   Tue Oct 16 17:49:28 2007 -0700

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 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 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 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");




More information about the wine-cvs mailing list