diff --git a/neo/idlib/containers/StrPool.h b/neo/idlib/containers/StrPool.h index 5971a7e8..65ab7fa6 100644 --- a/neo/idlib/containers/StrPool.h +++ b/neo/idlib/containers/StrPool.h @@ -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--;