Skip to content

Commit 5ef6711

Browse files
authored
Fix crash after failing to load SP game library
When loading a game in SP, UI_FreeAllSpecies can be called twice without an initialization in between if the SP game library could not be loaded. This results in a double free crash. This commit fixes the issue by resetting some variables after freeing so that calling free again is a no-op.
1 parent 235fb9e commit 5ef6711

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

code/ui/ui_main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,6 +2432,9 @@ void UI_FreeAllSpecies( void )
24322432
UI_FreeSpecies(&uiInfo.playerSpecies[i]);
24332433
}
24342434
free(uiInfo.playerSpecies);
2435+
2436+
uiInfo.playerSpeciesCount = 0;
2437+
uiInfo.playerSpecies = NULL;
24352438
}
24362439

24372440
/*

0 commit comments

Comments
 (0)