From 8ba435418b0d8b697910b348eff55146faa2dbcd Mon Sep 17 00:00:00 2001 From: Stef Velzel Date: Sat, 11 Oct 2014 21:02:57 +0200 Subject: [PATCH] Fixed win32 string conversion --- src/win32_init.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/win32_init.c b/src/win32_init.c index 51fe08ee3..5b1c18bb4 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -151,9 +151,9 @@ WCHAR* _glfwCreateWideStringFromUTF8(const char* source) if (!length) return NULL; - target = calloc(length + 1, sizeof(WCHAR)); + target = calloc(length, sizeof(WCHAR)); - if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, length + 1)) + if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, length)) { free(target); return NULL; @@ -173,9 +173,9 @@ char* _glfwCreateUTF8FromWideString(const WCHAR* source) if (!length) return NULL; - target = calloc(length + 1, sizeof(char)); + target = calloc(length, sizeof(char)); - if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, length + 1, NULL, NULL)) + if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, length, NULL, NULL)) { free(target); return NULL;