Fix 3/4 of issue #327: memory allocation issues.

This commit is contained in:
vrld
2011-11-08 23:22:48 +01:00
parent f9077ee1a6
commit aedf532cdc
3 changed files with 13 additions and 10 deletions
+6 -6
View File
@@ -36,12 +36,12 @@ namespace love
// Convert to UTF-8.
int ok = WideCharToMultiByte(CP_UTF8, 0, wstr, wide_len, utf8_str, utf8_size, 0, 0);
if(!ok)
{
delete [] utf8_str;
}
std::string ret;
if (ok)
ret = utf8_str;
return ok ? std::string(utf8_str) : std::string();
delete utf8_str;
return ret;
}
void replace_char(std::string & str, char find, char replace)
@@ -57,4 +57,4 @@ namespace love
} // love
#endif // LOVE_WINDOWS
#endif // LOVE_WINDOWS