Commit 14351fb0 authored by Mickael PHILIT's avatar Mickael PHILIT
Browse files

Prevent out of bounds access of CellData arrays

Since the GetMappedExtentValue is based on PointExtent,
 it can return an out of bound value in case of i == IMAX or j == JMAX or k == KMAX
so we decrement the value when it is different from 0 to stay bounded.
parent 298a18d2
......@@ -490,10 +490,18 @@ void vtkExtractStructuredGridHelper::CopyCellData(int inExt[6], int outExt[6],
for( K(ijk)=KMIN(outCellExt); K(ijk) <= KMAX(outCellExt); ++K(ijk) )
{
K(src_ijk) = useMapping ? this->GetMappedExtentValue(2, K(ijk)) : K(ijk);
if (K(src_ijk) == KMAX(this->InputWholeExtent) && K(src_ijk) != 0)
{
--K(src_ijk);
}
for( J(ijk)=JMIN(outCellExt); J(ijk) <= JMAX(outCellExt); ++J(ijk) )
{
J(src_ijk) = useMapping ? this->GetMappedExtentValue(1, J(ijk)) : J(ijk);
if (J(src_ijk) == JMAX(this->InputWholeExtent) && J(src_ijk) != 0)
{
--J(src_ijk);
}
if (canCopyRange)
{
......@@ -523,6 +531,10 @@ void vtkExtractStructuredGridHelper::CopyCellData(int inExt[6], int outExt[6],
{
I(src_ijk) = useMapping ? this->GetMappedExtentValue(0, I(ijk))
: I(ijk);
if (I(src_ijk) == IMAX(this->InputWholeExtent) && I(src_ijk) != 0)
{
--I(src_ijk);
}
// NOTE: since we are operating on cell extents, ComputePointID below
// really returns the cell ID
......
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