Skip to content

Commit

Permalink
Fix memory leak in guiConfirmRegistration
Browse files Browse the repository at this point in the history
  • Loading branch information
HybridDog authored and SmallJoker committed Jul 6, 2018
1 parent 738c8b1 commit 53dd781
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/gui/guiConfirmRegistration.cpp
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/util/string.cpp
Expand Up @@ -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));
Expand Down

0 comments on commit 53dd781

Please sign in to comment.