Fix crash when exiting with no game data

When shutting down with no game data, GameConfig is saved and the
pointer is nulled. If a joystick was present, a null dereference occurs
when the engine tries to save the joystick config later in the shutdown
sequence.

Add a check to avoid a crash in this scenario.
This commit is contained in:
Dale Whinham 2022-07-06 02:12:42 +01:00 committed by Christoph Oelckers
parent 390cd2ca98
commit ed4e23f1ec

View file

@ -169,7 +169,7 @@ void M_SaveJoystickConfig(IJoystickConfig *joy)
char key[32], value[32]; char key[32], value[32];
int axislen, numaxes; int axislen, numaxes;
if (M_SetJoystickConfigSection(joy, true)) if (GameConfig != NULL && M_SetJoystickConfigSection(joy, true))
{ {
GameConfig->ClearCurrentSection(); GameConfig->ClearCurrentSection();
if (!joy->IsSensitivityDefault()) if (!joy->IsSensitivityDefault())