mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2024-12-03 09:22:45 +00:00
Prevent segfault on shutdown
This should also happen on Windows, I'm really surprised this hasn't been noticed there
This commit is contained in:
parent
ba126dde3a
commit
cca3053069
1 changed files with 17 additions and 1 deletions
|
@ -168,7 +168,23 @@ ID_INLINE void idStrPool::FreeString( const idPoolStr* poolStr )
|
|||
{
|
||||
int i, hash;
|
||||
|
||||
assert( poolStr->numUsers >= 1 );
|
||||
/*
|
||||
* DG: numUsers can actually be 0 when shutting down the game, because then
|
||||
* first idCommonLocal::Quit() -> idCommonLocal::Shutdown() -> idLib::Shutdown()
|
||||
* -> idDict::Shutdown() -> idDict::globalKeys.Clear() and idDict::globalVars.Clear()
|
||||
* is called and then, from destructors,
|
||||
* ~idSessionLocal() => destroy idDict titleStorageVars -> ~idDict() -> idDict::Clear()
|
||||
* -> idDict::globalVars.FreeString() and idDict::globalKeys.FreeString() (this function)
|
||||
* is called, leading here.
|
||||
* So just return if poolStr->numUsers < 1, instead of segfaulting/asserting below
|
||||
* when i == -1 because nothing was found here. As there is no nice way to find out if
|
||||
* we're shutting down (at this point) just get rid of the following assertion:
|
||||
* assert( poolStr->numUsers >= 1 );
|
||||
*/
|
||||
if( poolStr->numUsers < 1 )
|
||||
return;
|
||||
// DG end
|
||||
|
||||
assert( poolStr->pool == this );
|
||||
|
||||
poolStr->numUsers--;
|
||||
|
|
Loading…
Reference in a new issue