don't rely on the game name string pointer to be valid for a whole lifetime

This commit is contained in:
Sebastian Krzyszkowiak 2019-03-28 15:25:37 +01:00
parent cdc99444e0
commit 6d7007b39e
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
2 changed files with 3 additions and 2 deletions

View file

@ -52,7 +52,7 @@ static char* GetDefaultWindowHeight(struct Game* game) {
SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char* name, struct Params params) {
struct Game* game = calloc(1, sizeof(struct Game));
game->_priv.name = name;
game->_priv.name = strdup(name);
game->_priv.params = params;
#ifdef ALLEGRO_MACOSX
@ -516,6 +516,7 @@ SYMBOL_EXPORT void libsuperderpy_destroy(struct Game* game) {
al_uninstall_system();
char** argv = game->_priv.argv;
bool restart = game->_priv.restart;
free(game->_priv.name);
free(game);
if (restart) {
#ifdef ALLEGRO_MACOSX

View file

@ -242,7 +242,7 @@ struct Game {
ALLEGRO_MUTEX* mutex;
const char* name;
char* name;
bool shutting_down; /*!< If true then shut down of the game is pending. */
bool restart; /*!< If true then restart of the game is pending. */