Skip to content

Commit

Permalink
Use SDL_QuitSubSystem instead of SDL_Quit.
Browse files Browse the repository at this point in the history
Fixes use-after-frees if FAudio quits after ProgramExit is called
  • Loading branch information
flibitijibibo committed Oct 8, 2024
1 parent 310e980 commit 23cba66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/FNAPlatform/SDL2_FNAPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,10 @@ public static void ProgramExit(object sender, EventArgs e)
Media.MediaPlayer.DisposeIfNecessary();

// This _should_ be the last SDL call we make...
SDL.SDL_Quit();
SDL.SDL_QuitSubSystem(
SDL.SDL_INIT_VIDEO |
SDL.SDL_INIT_GAMECONTROLLER
);
}

#endregion
Expand Down
5 changes: 4 additions & 1 deletion src/FNAPlatform/SDL3_FNAPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ public static void ProgramExit(object sender, EventArgs e)
Media.MediaPlayer.DisposeIfNecessary();

// This _should_ be the last SDL call we make...
SDL.SDL_Quit();
SDL.SDL_QuitSubSystem(
SDL.SDL_InitFlags.SDL_INIT_VIDEO |
SDL.SDL_InitFlags.SDL_INIT_GAMEPAD
);
}

#endregion
Expand Down

0 comments on commit 23cba66

Please sign in to comment.