[PATCH] kernel32: Handle negative dstlen in WideCharToMultiByte to remove todo_wine

Detlef Riekenberg wine.dev at web.de
Tue Jun 30 14:18:41 CDT 2009


---
 dlls/kernel32/locale.c         |    2 +-
 dlls/kernel32/tests/codepage.c |   12 ++++--------
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index fa17689..0d7b3f9 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -1893,7 +1893,7 @@ INT WINAPI WideCharToMultiByte( UINT page, DWORD flags, LPCWSTR src, INT srclen,
     const union cptable *table;
     int ret, used_tmp;
 
-    if (!src || (!dst && dstlen))
+    if (!src || (dstlen < 0) || (!dst && dstlen))
     {
         SetLastError( ERROR_INVALID_PARAMETER );
         return 0;
diff --git a/dlls/kernel32/tests/codepage.c b/dlls/kernel32/tests/codepage.c
index 9061241..791ec83 100644
--- a/dlls/kernel32/tests/codepage.c
+++ b/dlls/kernel32/tests/codepage.c
@@ -160,19 +160,15 @@ static void test_negative_dest_length(void)
     SetLastError( 0xdeadbeef );
     memset(buf,'x',sizeof(buf));
     len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buf, -1, NULL, NULL);
-    todo_wine {
-      ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER,
-         "WideCharToMultiByte(destlen -1): len=%d error=%x\n", len, GetLastError());
-    }
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER,
+        "WideCharToMultiByte(destlen -1): len=%d error=%x\n", len, GetLastError());
 
     /* Test return on -1000 dest length */
     SetLastError( 0xdeadbeef );
     memset(buf,'x',sizeof(buf));
     len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buf, -1000, NULL, NULL);
-    todo_wine {
-      ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER,
-         "WideCharToMultiByte(destlen -1000): len=%d error=%x\n", len, GetLastError());
-    }
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER,
+       "WideCharToMultiByte(destlen -1000): len=%d error=%x\n", len, GetLastError());
 
     /* Test return on INT_MAX dest length */
     SetLastError( 0xdeadbeef );
-- 
1.5.4.3


--=-OkERt57M9lqhdJ/JZCVQ--




More information about the wine-patches mailing list