Fixed segfault on exit by integrating pull request #378 by tomgreen66

This commit is contained in:
Stephen Saunders 2021-04-20 18:35:37 -04:00
parent 0aae6f0902
commit b14c3c21cb
2 changed files with 22 additions and 11 deletions

View file

@ -272,7 +272,6 @@ idSaveLoadParms::~idSaveLoadParms
*/
idSaveLoadParms::~idSaveLoadParms()
{
/* SRS - Don't need to repeat this code here, since auto-deletes are already handled by idSaveGameManager::FinishProcessor
for( int i = 0; i < files.Num(); ++i )
{
if( files[i]->type & SAVEGAMEFILE_AUTO_DELETE )
@ -280,7 +279,6 @@ idSaveLoadParms::~idSaveLoadParms()
delete files[i];
}
}
*/
}
/*

View file

@ -356,6 +356,7 @@ saveGameHandle_t idSessionLocal::LoadGameSync( const char* name, saveFileEntryLi
{
idSaveLoadParms& parms = processorLoadFiles->GetParmsNonConst();
saveGameHandle_t handle = 0;
bool checkDetailsFile = true;
{
// Put in a local block so everything will go in the global heap before the map change, but the heap is
@ -414,16 +415,28 @@ saveGameHandle_t idSessionLocal::LoadGameSync( const char* name, saveFileEntryLi
parms.errorCode = SAVEGAME_E_UNKNOWN;
}
if( parms.GetError() != SAVEGAME_E_NONE )
// SRS - check details file for compatibility before removing it from parms.files list
if( parms.GetError() == SAVEGAME_E_NONE )
{
return 0;
}
// Checks the description file to see if corrupted or if it's from a newer savegame
if( !LoadGameCheckDescriptionFile( parms ) )
{
return 0;
}
// Checks the details file to see if corrupted or if it's from a newer savegame
checkDetailsFile = LoadGameCheckDescriptionFile( parms );
}
// tomgreen66 - remove details file we added via auto_ptr to parms.files in InitLoadFiles above
for ( int i = 0; i < parms.files.Num(); ++i )
{
if ( parms.files[i] == gameDetailsFile.get() )
{
// details file reference will be deleted by auto_ptr so remove it from list and update file count
parms.files.RemoveIndexFast( i );
}
}
// SRS - return if savegame error or description file corrupt or not compatible
if( parms.GetError() != SAVEGAME_E_NONE || !checkDetailsFile )
{
return 0;
}
// Checks to see if loaded map is from a DLC map and if that DLC is active
if( !IsDLCAvailable( parms.description.GetMapName() ) )