From c9853070575fd65d171818777d1a6a06f34d6d3d Mon Sep 17 00:00:00 2001 From: KimLS Date: Thu, 31 May 2018 19:24:26 -0700 Subject: [PATCH] Patch detour to avoid a crash if an invalid ref is returned --- libs/recast/detour/src/DetourNavMeshQuery.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/recast/detour/src/DetourNavMeshQuery.cpp b/libs/recast/detour/src/DetourNavMeshQuery.cpp index 024d4a1fe..d27a142d0 100644 --- a/libs/recast/detour/src/DetourNavMeshQuery.cpp +++ b/libs/recast/detour/src/DetourNavMeshQuery.cpp @@ -1096,7 +1096,9 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef, // The API input has been cheked already, skip checking internal data. const dtMeshTile* neighbourTile = 0; const dtPoly* neighbourPoly = 0; - m_nav->getTileAndPolyByRefUnsafe(neighbourRef, &neighbourTile, &neighbourPoly); + if (m_nav->getTileAndPolyByRef(neighbourRef, &neighbourTile, &neighbourPoly) == DT_FAILURE) { + continue; + } if (!filter->passFilter(neighbourRef, neighbourTile, neighbourPoly)) continue;