Commit 3ce4968b authored by Kai Messerschmidt's avatar Kai Messerschmidt
Browse files

[FIX #486] Make sure that vector is only accessed in its bounds

in row 203 where the idx is calculated, z was negative in one case and flipped idx to nearly MAX_SIZE. idx was greater than the size of m_values.
Temporarily fixed it through setting z to 0 when it gets below 0
parent 9c9fd134
......@@ -198,10 +198,14 @@ void WBresenham::markVoxel( const WVector3i& voxel, const int axis, const WPosit
size_t nbXY = m_grid->getNbCoordsX() * m_grid->getNbCoordsY();
int x = voxel[0];
int y = voxel[1];
int z = voxel[2];
// There is one case, when z was -1, which flipped size_t to nearly MAX_SIZE
// Not sure how to fix this at the moment but this prevents the segfault
int z = ( voxel[2] < 0 ) ? 0 : voxel[2];
size_t idx = x + y * nbX + z * nbXY;
std::vector< double > distances;
WAssert( idx < m_values.size() , "idx is greater than the bounds of the vector" );
if( m_antialiased )
{
distances = computeDistances( idx, start, end );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment