[PATCH] kernel32: A neg. dstlen is a failure for WideCharToMultiByte

Detlef Riekenberg wine.dev at web.de
Fri Sep 18 18:08:17 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 9071ff9..2414981 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 || (!dst && dstlen) || (dstlen < 0))
     {
         SetLastError( ERROR_INVALID_PARAMETER );
         return 0;
diff --git a/dlls/kernel32/tests/codepage.c b/dlls/kernel32/tests/codepage.c
index 61d0c33..0c5fa7a 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


--=-EPSb1WoD/L/5Xn334BMs--




More information about the wine-patches mailing list