mirror of
https://github.com/celisej567/source-sdk-2013.git
synced 2026-09-23 20:09:45 +03:00
Fix strdup() leaks
This commit is contained in:
@@ -2511,7 +2511,7 @@ class CBreakableGibShooter : public CBaseEntity
|
||||
DECLARE_DATADESC();
|
||||
public:
|
||||
|
||||
const char *GetRandomTemplateModel( CPointTemplate *pTemplate );
|
||||
int GetRandomTemplateModelIndex( CPointTemplate *pTemplate );
|
||||
|
||||
void Precache( void );
|
||||
|
||||
@@ -2560,19 +2560,20 @@ END_DATADESC()
|
||||
LINK_ENTITY_TO_CLASS( env_break_shooter, CBreakableGibShooter );
|
||||
|
||||
|
||||
const char *CBreakableGibShooter::GetRandomTemplateModel( CPointTemplate *pTemplate )
|
||||
int CBreakableGibShooter::GetRandomTemplateModelIndex( CPointTemplate *pTemplate )
|
||||
{
|
||||
int iIndex = RandomInt( 0, pTemplate->GetNumTemplates() );
|
||||
char *iszTemplate = (char*)(STRING(Templates_FindByIndex(pTemplate->GetTemplateIndexForTemplate(iIndex))));
|
||||
char *iszTemplate = strdup(STRING(Templates_FindByIndex(pTemplate->GetTemplateIndexForTemplate(iIndex))));
|
||||
|
||||
CEntityMapData entData( iszTemplate );
|
||||
|
||||
// This might seem a little messy, but I think it's cheaper than creating the entity.
|
||||
char szModel[MAPKEY_MAXLENGTH];
|
||||
if (!entData.ExtractValue("model", szModel))
|
||||
return NULL;
|
||||
bool modelExtracted = entData.ExtractValue("model", szModel);
|
||||
|
||||
return strdup(szModel);
|
||||
free(iszTemplate);
|
||||
|
||||
return modelinfo->GetModelIndex( modelExtracted ? szModel : NULL );
|
||||
}
|
||||
|
||||
void CBreakableGibShooter::Precache( void )
|
||||
@@ -2604,7 +2605,7 @@ void CBreakableGibShooter::Shoot( void )
|
||||
if (m_iModelType == MODELTYPE_BREAKABLECHUNKS)
|
||||
iModelIndex = modelinfo->GetModelIndex( g_PropDataSystem.GetRandomChunkModel( STRING( GetModelName() ) ) );
|
||||
else if (m_iModelType == MODELTYPE_TEMPLATE)
|
||||
iModelIndex = modelinfo->GetModelIndex( GetRandomTemplateModel(pTemplate) );
|
||||
iModelIndex = GetRandomTemplateModelIndex( pTemplate );
|
||||
|
||||
// All objects except the first one in this run are marked as slaves...
|
||||
int slaveFlag = 0;
|
||||
|
||||
Reference in New Issue
Block a user