diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index 6e9ac14e0..a664b6081 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -2671,8 +2671,9 @@ namespace lime { if (model) { int size = std::wcslen (model->c_str ()); - char* result = (char*)malloc (size); + char* result = (char*)malloc (size + 1); std::wcstombs (result, model->c_str (), size); + result[size] = '\0'; delete model; return (vbyte*)result; @@ -2714,8 +2715,9 @@ namespace lime { if (vendor) { int size = std::wcslen (vendor->c_str ()); - char* result = (char*)malloc (size); + char* result = (char*)malloc (size + 1); std::wcstombs (result, vendor->c_str (), size); + result[size] = '\0'; delete vendor; return (vbyte*)result; @@ -2757,8 +2759,9 @@ namespace lime { if (path) { int size = std::wcslen (path->c_str ()); - char* result = (char*)malloc (size); + char* result = (char*)malloc (size + 1); std::wcstombs (result, path->c_str (), size); + result[size] = '\0'; delete path; return (vbyte*)result; @@ -2850,8 +2853,9 @@ namespace lime { if (label) { int size = std::wcslen (label->c_str ()); - char* result = (char*)malloc (size); + char* result = (char*)malloc (size + 1); std::wcstombs (result, label->c_str (), size); + result[size] = '\0'; delete label; return (vbyte*)result; @@ -2893,8 +2897,9 @@ namespace lime { if (name) { int size = std::wcslen (name->c_str ()); - char* result = (char*)malloc (size); + char* result = (char*)malloc (size + 1); std::wcstombs (result, name->c_str (), size); + result[size] = '\0'; delete name; return (vbyte*)result; @@ -2936,8 +2941,9 @@ namespace lime { if (version) { int size = std::wcslen (version->c_str ()); - char* result = (char*)malloc (size); + char* result = (char*)malloc (size + 1); std::wcstombs (result, version->c_str (), size); + result[size] = '\0'; delete version; return (vbyte*)result; diff --git a/project/src/backend/sdl/SDLSystem.cpp b/project/src/backend/sdl/SDLSystem.cpp index 9bcef4e36..c21f4843f 100644 --- a/project/src/backend/sdl/SDLSystem.cpp +++ b/project/src/backend/sdl/SDLSystem.cpp @@ -140,7 +140,7 @@ namespace lime { char folderPath[MAX_PATH] = ""; SHGetFolderPath (NULL, CSIDL_DESKTOPDIRECTORY, NULL, SHGFP_TYPE_CURRENT, folderPath); - WIN_StringToUTF8 (folderPath); + //WIN_StringToUTF8 (folderPath); std::wstring_convert> converter; result = new std::wstring (converter.from_bytes (folderPath)); @@ -177,7 +177,7 @@ namespace lime { char folderPath[MAX_PATH] = ""; SHGetFolderPath (NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, folderPath); - WIN_StringToUTF8 (folderPath); + //WIN_StringToUTF8 (folderPath); std::wstring_convert> converter; result = new std::wstring (converter.from_bytes (folderPath)); @@ -215,7 +215,7 @@ namespace lime { char folderPath[MAX_PATH] = ""; SHGetFolderPath (NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, folderPath); - WIN_StringToUTF8 (folderPath); + //WIN_StringToUTF8 (folderPath); std::wstring_convert> converter; result = new std::wstring (converter.from_bytes (folderPath)); @@ -255,7 +255,7 @@ namespace lime { char folderPath[MAX_PATH] = ""; SHGetFolderPath (NULL, CSIDL_PROFILE, NULL, SHGFP_TYPE_CURRENT, folderPath); - WIN_StringToUTF8 (folderPath); + //WIN_StringToUTF8 (folderPath); std::wstring_convert> converter; result = new std::wstring (converter.from_bytes (folderPath)); diff --git a/project/src/ui/FileDialog.cpp b/project/src/ui/FileDialog.cpp index c49ee1b48..8ed76afe7 100644 --- a/project/src/ui/FileDialog.cpp +++ b/project/src/ui/FileDialog.cpp @@ -14,8 +14,9 @@ namespace lime { if (!source) return NULL; int size = std::wcslen (source->c_str ()); - char* temp = (char*)malloc (size); + char* temp = (char*)malloc (size + 1); std::wcstombs (temp, source->c_str (), size); + temp[size] = '\0'; std::string* data = new std::string (temp); free (temp);