Skip to content

Commit

Permalink
Fix double-free crash
Browse files Browse the repository at this point in the history
Fixes #32
  • Loading branch information
keithbowes committed Jul 5, 2024
1 parent fba7d50 commit 7ddcbf4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libretro/libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int audio_2p_mode = 0;
bool already_checked_options = false;
bool libretro_supports_persistent_buffer = false;
bool libretro_supports_bitmasks = false;
struct retro_system_av_info *my_av_info = (retro_system_av_info*)malloc(sizeof(*my_av_info));
struct retro_system_av_info *my_av_info;

void retro_get_system_info(struct retro_system_info *info)
{
Expand Down Expand Up @@ -128,12 +128,15 @@ void retro_init(void)

environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level);

my_av_info = (retro_system_av_info*)malloc(sizeof(*my_av_info));

if (environ_cb(RETRO_ENVIRONMENT_GET_INPUT_BITMASKS, NULL))
libretro_supports_bitmasks = true;
}

void retro_deinit(void)
{
free(my_av_info);
libretro_supports_bitmasks = false;
}

Expand Down Expand Up @@ -405,7 +408,6 @@ void retro_unload_game(void)
render[i] = NULL;
}
}
free(my_av_info);
libretro_supports_persistent_buffer = false;
}

Expand Down

0 comments on commit 7ddcbf4

Please sign in to comment.