Skip to content
Snippets Groups Projects
Commit c1c3c0d0 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

Merge remote-tracking branch 'gl/dgobbi/stencil-iterator-overrun-6.3' into release-6.3

* gl/dgobbi/stencil-iterator-overrun-6.3:
  Fix a memory overrun in vtkImageStencilIterator.
parents 8792847d 2a652eb4
No related branches found
No related tags found
No related merge requests found
......@@ -114,7 +114,7 @@ void vtkImageStencilIterator<DType>::Initialize(
if (stencil)
{
this->HasStencil = true;
this->InStencil = true;
this->InStencil = false;
this->SpanIndexX = 0;
this->SpanIndexY = 0;
......@@ -155,11 +155,15 @@ void vtkImageStencilIterator<DType>::Initialize(
if (yOffset >= 0)
{
this->SpanMinY = 0;
// starting partway into the stencil, so add an offset
startOffset += yOffset;
}
else
{
this->SpanMinY = -yOffset;
// starting before start of stencil: subtract the increment that
// will be added in NextSpan() upon entry into stencil extent
startOffset -= 1;
}
if (stencilExtent[3] > extent[3])
......@@ -175,11 +179,18 @@ void vtkImageStencilIterator<DType>::Initialize(
if (zOffset >= 0)
{
this->SpanMinZ = 0;
// starting partway into the stencil, so add an offset
startOffset += zOffset*this->SpanSliceIncrement;
}
else
{
this->SpanMinZ = -zOffset;
// starting before start of stencil: subtract the increment that
// will be added in NextSpan() upon entry into stencil extent
if (yOffset >= 0)
{
startOffset -= 1 + this->SpanSliceEndIncrement;
}
}
if (stencilExtent[5] > extent[5])
......@@ -202,14 +213,18 @@ void vtkImageStencilIterator<DType>::Initialize(
vtkImageStencilIteratorFriendship::GetExtentLists(stencil) +
startOffset;
// Holds the current position within the span list for the current row
this->SetSpanState(this->SpanMinX);
// Get the current position within the span list for the current row
if (yOffset >= 0 && zOffset >= 0)
{
// If starting within stencil extent, check stencil immediately
this->InStencil = true;
this->SetSpanState(this->SpanMinX);
}
}
else
{
this->SpanCountPointer = 0;
this->SpanListPointer = 0;
this->InStencil = false;
}
}
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment