Fix gettext memory leaks
authorsapier <Sapier at GMX dot net>
Thu, 9 May 2013 21:14:32 +0000 (23:14 +0200)
committerPilzAdam <pilzadam@minetest.net>
Fri, 10 May 2013 09:31:00 +0000 (11:31 +0200)
src/guiMainMenu.cpp

index 48e41bb816ccdedf94bf3e2acef007b1d1a70bf8..9966b9fa77a36fd5fd3810aabc9321c81478a7d0 100644 (file)
@@ -483,16 +483,20 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
                                {
                                        core::rect<s32> rect(0, 0, 390, 20);
                                        rect += m_topleft_client + v2s32(50, 10);
-                                       Environment->addStaticText(wgettext("Favorites:"),
+                                       wchar_t* text = wgettext("Favorites:");
+                                       Environment->addStaticText(text,
                                                rect, false, true, this, GUI_ID_SERVERLIST_TITLE);
+                                       delete[] text;
                                }
                        } else {
                                m_data->servers = ServerList::getOnline();
                                {
                                        core::rect<s32> rect(0, 0, 390, 20);
                                        rect += m_topleft_client + v2s32(50, 10);
-                                       Environment->addStaticText(wgettext("Public Server List:"),
+                                       wchar_t* text = wgettext("Public Server List:");
+                                       Environment->addStaticText(text,
                                                rect, false, true, this, GUI_ID_SERVERLIST_TITLE);
+                                       delete[] text;
                                }
                        }
 #else
@@ -500,8 +504,10 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
                        {
                                core::rect<s32> rect(0, 0, 390, 20);
                                rect += m_topleft_client + v2s32(50, 10);
-                               Environment->addStaticText(wgettext("Favorites:"),
+                               wchar_t* text = wgettext("Favorites:");
+                               Environment->addStaticText(text,
                                        rect, false, true, this, GUI_ID_SERVERLIST_TITLE);
+                               delete[] text;
                        }
 #endif
                        updateGuiServerList();
@@ -1372,9 +1378,11 @@ bool GUIMainMenu::OnEvent(const SEvent& event)
                                readInput(&cur);
                                if (getTab() == TAB_MULTIPLAYER && cur.address == L"")
                                {
+                                       wchar_t* text = wgettext("Address required.");
                                        (new GUIMessageMenu(env, parent, -1, menumgr,
-                                                       wgettext("Address required."))
+                                                       text)
                                                        )->drop();
+                                       delete[] text;
                                        return true;
                                }
                                acceptInput();