summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2019-01-20 22:48:16 -0800
committerMike Pavone <pavone@retrodev.com>2019-01-20 22:48:16 -0800
commit3916a1dcdac01b4a7da14c9561707046af6a1ef5 (patch)
tree75123bcf94b2c80cdaf11dd2bc1cccfe5011491f
parentef9e02ca28b67a25c1cd9e203c2e104446b0a5ed (diff)
Don't leak a system context when a game is unloaded
-rw-r--r--libblastem.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libblastem.c b/libblastem.c
index 8b2ea74..b6c5cf4 100644
--- a/libblastem.c
+++ b/libblastem.c
@@ -56,6 +56,9 @@ RETRO_API void retro_init(void)
RETRO_API void retro_deinit(void)
{
+ if (current_system) {
+ retro_unload_game();
+ }
}
RETRO_API unsigned retro_api_version(void)
@@ -185,11 +188,14 @@ RETRO_API bool retro_load_game_special(unsigned game_type, const struct retro_ga
/* Unloads a currently loaded game. */
RETRO_API void retro_unload_game(void)
{
-
free(media.dir);
free(media.name);
free(media.extension);
-
+ media.dir = media.name = media.extension = NULL;
+ //buffer is freed by the context
+ media.buffer = NULL;
+ current_system->free_context(current_system);
+ current_system = NULL;
}
/* Gets region of game. */