ConnectionArray list index access bug fixed where index == count would be allowed

This commit is contained in:
vis2k 2018-06-08 11:46:49 +02:00
parent e505cbd5f4
commit c41ca4d824

View File

@ -56,7 +56,7 @@ public NetworkConnection Get(int connId)
return m_LocalConnections[Mathf.Abs(connId) - 1];
}
if (connId < 0 || connId > m_Connections.Count)
if (connId >= connections.Count)
{
if (LogFilter.logWarn) { Debug.LogWarning("ConnectionArray Get invalid index " + connId); }
return null;
@ -68,7 +68,7 @@ public NetworkConnection Get(int connId)
// call this if the connection may not exist (in disconnect handler)
public NetworkConnection GetUnsafe(int connId)
{
if (connId < 0 || connId > m_Connections.Count)
if (connId < 0 || connId >= m_Connections.Count)
{
return null;
}
@ -83,7 +83,7 @@ public void Remove(int connId)
return;
}
if (connId < 0 || connId > m_Connections.Count)
if (connId < 0 || connId >= m_Connections.Count)
{
if (LogFilter.logWarn) { Debug.LogWarning("ConnectionArray Remove invalid index " + connId); }
return;