kernel32: Add an overflow test for MultiByteToWideChar

Dmitry Timoshkov dmitry at codeweavers.com
Fri May 18 06:21:35 CDT 2007


Hello,

in the bug 8425 the behaviour of MultiByteToWideChar regarding an overflow
was questioned, here is a test that confirms that current behaviour is correct.

Changelog:
    kernel32: Add an overflow test for MultiByteToWideChar.

---
 dlls/kernel32/tests/codepage.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/dlls/kernel32/tests/codepage.c b/dlls/kernel32/tests/codepage.c
index 89b6ef0..bde9f82 100644
--- a/dlls/kernel32/tests/codepage.c
+++ b/dlls/kernel32/tests/codepage.c
@@ -137,6 +137,12 @@ static void test_negative_source_length(void)
     len = MultiByteToWideChar(CP_ACP, 0, "foobar", -2002, bufW, 10);
     ok(len == 7 && !mylstrcmpW(bufW, foobarW) && GetLastError() == 0xdeadbeef,
        "MultiByteToWideChar(-2002): len=%d error=%u\n", len, GetLastError());
+
+    SetLastError(0xdeadbeef);
+    memset(bufW, 'x', sizeof(bufW));
+    len = MultiByteToWideChar(CP_ACP, 0, "foobar", -1, bufW, 6);
+    ok(len == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
+       "MultiByteToWideChar(-1): len=%d error=%u\n", len, GetLastError());
 }
 
 static void test_overlapped_buffers(void)
-- 
1.5.1.3






More information about the wine-patches mailing list