Skip to content

Commit

Permalink
Fix use-after-free on shutdown in options/audio
Browse files Browse the repository at this point in the history
Closes #2132.
  • Loading branch information
lmoureaux committed Jan 4, 2024
1 parent 3a3b1d7 commit 23bf528
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions client/audio/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,11 @@ void audio_set_volume(double volume)
*/
void audio_shutdown()
{
// Already shut down
if (selected_plugin < 0) {
return;
}

// avoid infinite loop at end of game
audio_stop();

Expand All @@ -624,6 +629,9 @@ void audio_shutdown()
secfile_destroy(ms_tagfile);
ms_tagfile = nullptr;
}

// Mark shutdown
selected_plugin = -1;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions client/client_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,8 @@ void client_exit()
options_save(log_option_save_msg);
}

audio_shutdown();

overview_free();
tileset_free(tileset);

Expand Down

0 comments on commit 23bf528

Please sign in to comment.