diff options
author | HybridDog <ovvv@web.de> | 2018-06-27 18:09:45 +0200 |
---|---|---|
committer | SmallJoker <mk939@ymail.com> | 2018-07-06 11:13:18 +0200 |
commit | 53dd7819277c53954d1298dfffa5287c306db8d0 (patch) | |
tree | a9e4e1ce5ab0fe2687bee86bb0dc511b3e8130a5 | |
parent | 738c8b102ba02b6d243091759f2529614fc3c32b (diff) | |
download | minetest-53dd7819277c53954d1298dfffa5287c306db8d0.tar.gz minetest-53dd7819277c53954d1298dfffa5287c306db8d0.tar.bz2 minetest-53dd7819277c53954d1298dfffa5287c306db8d0.zip |
Fix memory leak in guiConfirmRegistration
-rw-r--r-- | src/gui/guiConfirmRegistration.cpp | 7 | ||||
-rw-r--r-- | src/util/string.cpp | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/gui/guiConfirmRegistration.cpp b/src/gui/guiConfirmRegistration.cpp index 92ca94d42..fea9f5cda 100644 --- a/src/gui/guiConfirmRegistration.cpp +++ b/src/gui/guiConfirmRegistration.cpp @@ -99,9 +99,10 @@ void GUIConfirmRegistration::regenerateGui(v2u32 screensize) snprintf(info_text_buf, sizeof(info_text_buf), info_text_template.c_str(), address.c_str(), m_playername.c_str()); - gui::IGUIEditBox *e = new gui::intlGUIEditBox( - utf8_to_wide_c(info_text_buf), true, Environment, this, - ID_message, rect2, false, true); + wchar_t *info_text_buf_wide = utf8_to_wide_c(info_text_buf); + gui::IGUIEditBox *e = new gui::intlGUIEditBox(info_text_buf_wide, true, + Environment, this, ID_message, rect2, false, true); + delete[] info_text_buf_wide; e->drop(); e->setMultiLine(true); e->setWordWrap(true); diff --git a/src/util/string.cpp b/src/util/string.cpp index 25f573420..388e8d293 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -167,6 +167,8 @@ std::string wide_to_utf8(const std::wstring &input) #endif // _WIN32 +// You must free the returned string! +// The returned string is allocated using new wchar_t *utf8_to_wide_c(const char *str) { std::wstring ret = utf8_to_wide(std::string(str)); |