Make a copy of the passed argument (will otherwise give undef references)

This commit is contained in:
simon.kagstrom 2010-02-21 08:02:06 +00:00
parent 63b7d45688
commit 4c9590e65d

View File

@ -1,5 +1,6 @@
#include "status_bar.hh" #include "status_bar.hh"
#include "gui.hh" #include "gui.hh"
#include "utils.hh"
StatusBar::StatusBar() : Menu(Gui::gui->small_font), TimeoutHandler() StatusBar::StatusBar() : Menu(Gui::gui->small_font), TimeoutHandler()
{ {
@ -12,7 +13,7 @@ StatusBar::StatusBar() : Menu(Gui::gui->small_font), TimeoutHandler()
void StatusBar::queueMessage(const char *message) void StatusBar::queueMessage(const char *message)
{ {
this->messages[this->head] = message; this->messages[this->head] = xstrdup(message);
/* If this is the first message, display it as soon as possible */ /* If this is the first message, display it as soon as possible */
if (this->head == this->tail) if (this->head == this->tail)
@ -49,6 +50,7 @@ void StatusBar::timeoutCallback()
} }
else else
this->setText(NULL); this->setText(NULL);
free((void *)this->cur_message);
} }
void StatusBar::draw(SDL_Surface *where) void StatusBar::draw(SDL_Surface *where)