From e690916f68d651147653ffae3be1c17fa5edfdbe Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Fri, 18 May 2007 20:21:35 +0900 Subject: [PATCH] kernel32: Add an overflow test for MultiByteToWideChar. --- dlls/kernel32/tests/codepage.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dlls/kernel32/tests/codepage.c b/dlls/kernel32/tests/codepage.c index 89b6ef0384..bde9f82551 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)