Fix crash in finding path over navmesh (#6338)
- Avoid access to the path vector element out of range. polygonPath.front() in some cases might reference to a first element of empty vector. Copy the value into a local variable to be able to access later.
- Avoid redundant polygon path reallocations. Use separate variable to store size and make all operations in-place.
Better to review each change in a separate commit.
Fixes #6338 (closed).