From 7a1f5f2253f93b05e0cd3d6000673efbcdd7a8b9 Mon Sep 17 00:00:00 2001 From: The Fatcat Date: Wed, 10 Sep 2025 20:50:57 -0500 Subject: [PATCH 1/2] Fix Client Crashes from Invalid Banners --- src/game/shared/tf/tf_weapon_buff_item.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/game/shared/tf/tf_weapon_buff_item.cpp b/src/game/shared/tf/tf_weapon_buff_item.cpp index 747a1a6316b..5a3cbc6b56e 100644 --- a/src/game/shared/tf/tf_weapon_buff_item.cpp +++ b/src/game/shared/tf/tf_weapon_buff_item.cpp @@ -310,12 +310,20 @@ void CTFBuffItem::CreateBanner() if ( !pBanner ) return; + int iBuffType = GetBuffType(); + // Prevent Crashes From Invalid Buff Types + if ( iBuffType > ARRAYSIZE(BannerModels) || iBuffType <= 0 ) + { + DevMsg("Invalid buff type %d, Not Creating Banner\n", iBuffType); + return; + } + //Assert( iBuffType > 0 ); //Assert( iBuffType <= ARRAYSIZE(BannerModels) ); pBanner->m_nSkin = 0; - pBanner->InitializeAsClientEntity( BannerModels[GetBuffType()-1], RENDER_GROUP_OPAQUE_ENTITY ); + pBanner->InitializeAsClientEntity( BannerModels[iBuffType-1], RENDER_GROUP_OPAQUE_ENTITY ); pBanner->SetBuffItem( this ); - pBanner->SetBuffType( GetBuffType() ); + pBanner->SetBuffType( iBuffType ); pBanner->ForceClientSideAnimationOn(); SetBanner( pBanner ); int iSpine = pPlayer->LookupBone( "bip_spine_3" ); From 0cd0bac283bf6c090cbae505e4021682b02f827b Mon Sep 17 00:00:00 2001 From: The Fatcat Date: Wed, 10 Sep 2025 21:29:20 -0500 Subject: [PATCH 2/2] Move prevention above creating the Banner --- src/game/shared/tf/tf_weapon_buff_item.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game/shared/tf/tf_weapon_buff_item.cpp b/src/game/shared/tf/tf_weapon_buff_item.cpp index 5a3cbc6b56e..d395067aa6d 100644 --- a/src/game/shared/tf/tf_weapon_buff_item.cpp +++ b/src/game/shared/tf/tf_weapon_buff_item.cpp @@ -306,10 +306,6 @@ void CTFBuffItem::CreateBanner() if ( !pPlayer || !pPlayer->IsAlive() ) return; - C_TFBuffBanner* pBanner = new C_TFBuffBanner; - if ( !pBanner ) - return; - int iBuffType = GetBuffType(); // Prevent Crashes From Invalid Buff Types if ( iBuffType > ARRAYSIZE(BannerModels) || iBuffType <= 0 ) @@ -317,6 +313,10 @@ void CTFBuffItem::CreateBanner() DevMsg("Invalid buff type %d, Not Creating Banner\n", iBuffType); return; } + + C_TFBuffBanner* pBanner = new C_TFBuffBanner; + if ( !pBanner ) + return; //Assert( iBuffType > 0 ); //Assert( iBuffType <= ARRAYSIZE(BannerModels) );