avoid out of bounds deref warning

This commit is contained in:
Arne Morten Kvarving 2023-05-09 10:34:37 +02:00
parent 1c8df58353
commit cd4aec3a0b

View File

@ -166,7 +166,7 @@ bool HexGridIntersectionTools::planeTriangleIntersection( const cvf::Plane& plan
if ( onPosSide[2] ) topVx = 3;
// Case 3a: Two negative distances and the last is within tolerance of zero.
if ( sqrSignedDistances[topVx - 1] < sqrDistanceTolerance )
if ( topVx > 0 && sqrSignedDistances[topVx - 1] < sqrDistanceTolerance )
{
return false;
}
@ -178,7 +178,7 @@ bool HexGridIntersectionTools::planeTriangleIntersection( const cvf::Plane& plan
if ( !onPosSide[2] ) topVx = 3;
// Case 3a: Two positive distances and the last is within tolerance of zero.
if ( sqrSignedDistances[topVx - 1] > -sqrDistanceTolerance )
if ( topVx > 0 && sqrSignedDistances[topVx - 1] > -sqrDistanceTolerance )
{
return false;
}