From 991c08f222e8b3d3a2cc73dd40abe07d495fd047 Mon Sep 17 00:00:00 2001 From: Mikko Mononen Date: Thu, 19 Sep 2013 20:17:41 +0200 Subject: [PATCH] Fix for google code Issue 221 - fixed agent idx bound checks --- DetourCrowd/Source/DetourCrowd.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/DetourCrowd/Source/DetourCrowd.cpp b/DetourCrowd/Source/DetourCrowd.cpp index 21cf871..42b5b19 100644 --- a/DetourCrowd/Source/DetourCrowd.cpp +++ b/DetourCrowd/Source/DetourCrowd.cpp @@ -489,7 +489,7 @@ const dtCrowdAgent* dtCrowd::getAgent(const int idx) void dtCrowd::updateAgentParameters(const int idx, const dtCrowdAgentParams* params) { - if (idx < 0 || idx > m_maxAgents) + if (idx < 0 || idx >= m_maxAgents) return; memcpy(&m_agents[idx].params, params, sizeof(dtCrowdAgentParams)); } @@ -567,7 +567,7 @@ void dtCrowd::removeAgent(const int idx) bool dtCrowd::requestMoveTargetReplan(const int idx, dtPolyRef ref, const float* pos) { - if (idx < 0 || idx > m_maxAgents) + if (idx < 0 || idx >= m_maxAgents) return false; dtCrowdAgent* ag = &m_agents[idx]; @@ -594,7 +594,7 @@ bool dtCrowd::requestMoveTargetReplan(const int idx, dtPolyRef ref, const float* /// The request will be processed during the next #update(). bool dtCrowd::requestMoveTarget(const int idx, dtPolyRef ref, const float* pos) { - if (idx < 0 || idx > m_maxAgents) + if (idx < 0 || idx >= m_maxAgents) return false; if (!ref) return false; @@ -616,7 +616,7 @@ bool dtCrowd::requestMoveTarget(const int idx, dtPolyRef ref, const float* pos) bool dtCrowd::requestMoveVelocity(const int idx, const float* vel) { - if (idx < 0 || idx > m_maxAgents) + if (idx < 0 || idx >= m_maxAgents) return false; dtCrowdAgent* ag = &m_agents[idx]; @@ -633,7 +633,7 @@ bool dtCrowd::requestMoveVelocity(const int idx, const float* vel) bool dtCrowd::resetMoveTarget(const int idx) { - if (idx < 0 || idx > m_maxAgents) + if (idx < 0 || idx >= m_maxAgents) return false; dtCrowdAgent* ag = &m_agents[idx];