reg/tests: Exclude the null terminating character from MultiByteToWideChar conversion.

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hugh McMaster 2016-09-01 13:37:06 +00:00 committed by Alexandre Julliard
parent 716e9c93e4
commit 6d72a0cca3
1 changed files with 5 additions and 3 deletions

View File

@ -727,17 +727,19 @@ static BOOL test_import_str_(unsigned line, const char *file_contents, DWORD *rc
#define test_import_wstr(c,r) test_import_wstr_(__LINE__,c,r) #define test_import_wstr(c,r) test_import_wstr_(__LINE__,c,r)
static BOOL test_import_wstr_(unsigned line, const char *file_contents, DWORD *rc) static BOOL test_import_wstr_(unsigned line, const char *file_contents, DWORD *rc)
{ {
int len, memsize; int lenA, len, memsize;
WCHAR *wstr; WCHAR *wstr;
HANDLE regfile; HANDLE regfile;
DWORD written; DWORD written;
BOOL ret; BOOL ret;
len = MultiByteToWideChar(CP_UTF8, 0, file_contents, -1, NULL, 0); lenA = strlen(file_contents);
len = MultiByteToWideChar(CP_UTF8, 0, file_contents, lenA, NULL, 0);
memsize = len * sizeof(WCHAR); memsize = len * sizeof(WCHAR);
wstr = HeapAlloc(GetProcessHeap(), 0, memsize); wstr = HeapAlloc(GetProcessHeap(), 0, memsize);
if (!wstr) return FALSE; if (!wstr) return FALSE;
MultiByteToWideChar(CP_UTF8, 0, file_contents, -1, wstr, memsize); MultiByteToWideChar(CP_UTF8, 0, file_contents, lenA, wstr, memsize);
regfile = CreateFileA("test.reg", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, regfile = CreateFileA("test.reg", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL); FILE_ATTRIBUTE_NORMAL, NULL);