Bia10 / recastnavigation

Automatically exported from code.google.com/p/recastnavigation
zlib License
1 stars 0 forks source link

Uninitalized array in DetourCrowd can cause infinite wait loop #228

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi there,

After our game hanged several times when an agent couldn't find a position on 
on the navmesh, I started digging into your code and found an uninitialized 
array of floats in DetourCrowd.cpp:dtCrowd::addAgent.

findNearestPoly() doesn't necessarily initialize nearestPt, leaving nearest[] 
uninitialized. 

I solved it by initializing nearest[] to pos[].

Diff below!

Cheers,

Martijn

Index: DetourCrowd.cpp
===================================================================
--- DetourCrowd.cpp (revision 7928)
+++ DetourCrowd.cpp (revision 7929)
@@ -523,6 +523,9 @@

    // Find nearest position on navmesh and place the agent there.
    float nearest[3];
+   dtVcopy(nearest, pos);  // Two Tribes Addition: make sure nearest[] is 
initialized to a sensible value
+                           // because findNearestPoly() doesn't necessarily 
initialize nearestPt, leaving nearest[]
+                           // uninitialized.
    dtPolyRef ref;
    m_navquery->findNearestPoly(pos, m_ext, &m_filter, &ref, nearest);

Original issue reported on code.google.com by mreuvers...@gmail.com on 3 Jan 2013 at 2:52

GoogleCodeExporter commented 8 years ago
Fixed in github repo:
https://github.com/memononen/recastnavigation

Original comment by memono...@gmail.com on 17 Sep 2013 at 7:30