mirror of
https://github.com/recastnavigation/recastnavigation.git
synced 2026-10-02 15:05:40 +00:00
Fail when too many nodes are requested
dtNavMeshQuery now fails initialization if too many nodes are requested in the node pool. This could cause wrong paths and infinite loops to happen if the node indices started overflowing dtNodeIndex or dtNode::pidx. Fix #178
This commit is contained in:
committed by
Ben Hymers
parent
0f8ebe285e
commit
09afa02f4a
@@ -165,6 +165,9 @@ dtNavMeshQuery::~dtNavMeshQuery()
|
||||
/// This function can be used multiple times.
|
||||
dtStatus dtNavMeshQuery::init(const dtNavMesh* nav, const int maxNodes)
|
||||
{
|
||||
if (maxNodes > DT_NULL_IDX || maxNodes > (1 << DT_NODE_PARENT_BITS) - 1)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
m_nav = nav;
|
||||
|
||||
if (!m_nodePool || m_nodePool->getMaxNodes() < maxNodes)
|
||||
@@ -195,7 +198,6 @@ dtStatus dtNavMeshQuery::init(const dtNavMesh* nav, const int maxNodes)
|
||||
m_tinyNodePool->clear();
|
||||
}
|
||||
|
||||
// TODO: check the open list size too.
|
||||
if (!m_openList || m_openList->getCapacity() < maxNodes)
|
||||
{
|
||||
if (m_openList)
|
||||
|
||||
Reference in New Issue
Block a user