mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-21 13:41:41 +00:00
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.
This commit is contained in:
parent
ed1953b811
commit
79665cea66
1 changed files with 7 additions and 7 deletions
|
@ -199,11 +199,14 @@ namespace DetourNavigator
|
||||||
++smoothPathSize;
|
++smoothPathSize;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (offMeshConnection && inRange(result->mResultPos, steerTarget->steerPos, slop))
|
|
||||||
|
dtPolyRef polyRef = polygonPath.front();
|
||||||
|
osg::Vec3f polyPos = result->mResultPos;
|
||||||
|
|
||||||
|
if (offMeshConnection && inRange(polyPos, steerTarget->steerPos, slop))
|
||||||
{
|
{
|
||||||
// Advance the path up to and over the off-mesh connection.
|
// Advance the path up to and over the off-mesh connection.
|
||||||
dtPolyRef prevRef = 0;
|
dtPolyRef prevRef = 0;
|
||||||
dtPolyRef polyRef = polygonPath.front();
|
|
||||||
std::size_t npos = 0;
|
std::size_t npos = 0;
|
||||||
while (npos < polygonPath.size() && polyRef != steerTarget->steerPosRef)
|
while (npos < polygonPath.size() && polyRef != steerTarget->steerPosRef)
|
||||||
{
|
{
|
||||||
|
@ -233,14 +236,11 @@ namespace DetourNavigator
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move position at the other side of the off-mesh link.
|
// Move position at the other side of the off-mesh link.
|
||||||
if (dtStatusFailed(navMeshQuery.getPolyHeight(polygonPath.front(), endPos.ptr(), &iterPos.y())))
|
polyPos = endPos;
|
||||||
return Status::GetPolyHeightFailed;
|
|
||||||
iterPos.x() = endPos.x();
|
|
||||||
iterPos.z() = endPos.z();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dtStatusFailed(navMeshQuery.getPolyHeight(polygonPath.front(), result->mResultPos.ptr(), &iterPos.y())))
|
if (dtStatusFailed(navMeshQuery.getPolyHeight(polyRef, polyPos.ptr(), &iterPos.y())))
|
||||||
return Status::GetPolyHeightFailed;
|
return Status::GetPolyHeightFailed;
|
||||||
iterPos.x() = result->mResultPos.x();
|
iterPos.x() = result->mResultPos.x();
|
||||||
iterPos.z() = result->mResultPos.z();
|
iterPos.z() = result->mResultPos.z();
|
||||||
|
|
Loading…
Reference in a new issue