mirror of
https://github.com/glfw/glfw.git
synced 2024-11-14 06:23:50 +00:00
Fixed Win32 string conversion.
Specifying -1 as the source string size makes the returned size include the null terminator. Closes #364.
This commit is contained in:
parent
a6c57dc6f1
commit
653079b792
@ -151,9 +151,9 @@ WCHAR* _glfwCreateWideStringFromUTF8(const char* source)
|
|||||||
if (!length)
|
if (!length)
|
||||||
return NULL;
|
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);
|
free(target);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -173,9 +173,9 @@ char* _glfwCreateUTF8FromWideString(const WCHAR* source)
|
|||||||
if (!length)
|
if (!length)
|
||||||
return NULL;
|
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);
|
free(target);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user