[PATCH] reg/tests: Exclude the null terminating character from MultiByteToWideChar conversion
Hugh McMaster
hugh.mcmaster at outlook.com
Thu Sep 1 08:37:06 CDT 2016
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
programs/reg/tests/reg.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index 715cdbd..1e3d1d2 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -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)
static BOOL test_import_wstr_(unsigned line, const char *file_contents, DWORD *rc)
{
- int len, memsize;
+ int lenA, len, memsize;
WCHAR *wstr;
HANDLE regfile;
DWORD written;
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);
wstr = HeapAlloc(GetProcessHeap(), 0, memsize);
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,
FILE_ATTRIBUTE_NORMAL, NULL);
--
2.7.4
More information about the wine-patches
mailing list