Skip to content

Commit

Permalink
Fixed client crash caused by invalid blip icon
Browse files Browse the repository at this point in the history
  • Loading branch information
ccw808 committed Jan 25, 2018
1 parent 01885cb commit 288cff1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Client/game_sa/CMarkerSA.cpp
Expand Up @@ -42,7 +42,10 @@ void CMarkerSA::Init ( void )
VOID CMarkerSA::SetSprite ( eMarkerSprite Sprite = (eMarkerSprite)MARKER_SPRITE_NONE )
{
DEBUG_TRACE("VOID CMarkerSA::SetSprite ( eMarkerSprite Sprite = (eMarkerSprite)MARKER_SPRITE_NONE )");
internalInterface->nBlipSprite = Sprite;
if (Sprite >= MARKER_SPRITE_NONE && Sprite <= MARKER_SPRITE_SPRAY)
{
internalInterface->nBlipSprite = Sprite;
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientRadarMarkerManager.h
Expand Up @@ -40,6 +40,7 @@ class CClientRadarMarkerManager
inline std::list < CClientRadarMarker* > ::const_iterator IterEnd ( void ) { return m_Markers.end (); };

bool Exists ( CClientRadarMarker* pMarker );
static bool IsValidIcon ( unsigned long ulIcon ) { return ulIcon <= RADAR_MARKER_LIMIT; }

private:
inline void AddToList ( CClientRadarMarker* pMarker ) { m_Markers.push_back ( pMarker ); };
Expand Down
11 changes: 10 additions & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaBlipDefs.cpp
Expand Up @@ -77,6 +77,11 @@ int CLuaBlipDefs::CreateBlip ( lua_State* luaVM )
argStream.ReadNumber ( sOrdering, 0 );
argStream.ReadNumber ( usVisibleDistance, 16383 );

if (!CClientRadarMarkerManager::IsValidIcon(ucIcon))
{
argStream.SetCustomError("Invalid icon");
}

if ( !argStream.HasErrors () )
{
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
Expand Down Expand Up @@ -129,7 +134,11 @@ int CLuaBlipDefs::CreateBlipAttachedTo ( lua_State* luaVM )
argStream.ReadNumber ( sOrdering, 0 );
argStream.ReadNumber ( usVisibleDistance, 16383 );

// Element in place?
if (!CClientRadarMarkerManager::IsValidIcon(ucIcon))
{
argStream.SetCustomError("Invalid icon");
}

if ( !argStream.HasErrors () )
{
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
Expand Down
10 changes: 10 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaBlipDefs.cpp
Expand Up @@ -85,6 +85,11 @@ int CLuaBlipDefs::CreateBlip ( lua_State* luaVM )
else
argStream.ReadUserData ( pVisibleTo, m_pRootElement );

if (!CBlipManager::IsValidIcon(ucIcon))
{
argStream.SetCustomError("Invalid icon");
}

if ( !argStream.HasErrors () )
{
CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
Expand Down Expand Up @@ -140,6 +145,11 @@ int CLuaBlipDefs::CreateBlipAttachedTo ( lua_State* luaVM )
else
argStream.ReadUserData ( pVisibleTo, m_pRootElement );

if (!CBlipManager::IsValidIcon(ucIcon))
{
argStream.SetCustomError("Invalid icon");
}

if ( !argStream.HasErrors () )
{
CResource * resource = m_pLuaManager->GetVirtualMachineResource ( luaVM );
Expand Down

0 comments on commit 288cff1

Please sign in to comment.