MantisBT - ITK
View Issue Details
0008960ITKpublic2009-05-05 11:052010-11-07 01:57
Luis Ibanez 
Luis Ibanez 
normalminorhave not tried
closedfixed 
 
 
backlog
0008960: Image Iterators do not validate region in constructor
The constructors of the ImageRegionConstIterator and ImageRegionConstIteratorWithIndex do not verify that the region passed as argument is fully contained in the image Buffered Region.
As a result it is possible to pass as argument to the constructor, a region that is not inside of the image and to force the iterator to produce pointers that are outside of the image buffer.
No tags attached.
Issue History
2009-05-05 11:05Luis IbanezNew Issue
2009-05-05 11:06Luis IbanezSummaryImageItartor doesn't validate region in constructor => Image Iterators do not validate region in constructor
2009-05-05 11:07Luis IbanezNote Added: 0016288
2009-05-05 11:17Luis IbanezNote Added: 0016289
2009-05-06 18:39Luis IbanezStatusnew => assigned
2009-05-06 18:39Luis IbanezAssigned To => Luis Ibanez
2010-11-07 01:57Luis IbanezSprint Status => backlog
2010-11-07 01:57Luis IbanezNote Added: 0022979
2010-11-07 01:57Luis IbanezStatusassigned => closed
2010-11-07 01:57Luis IbanezResolutionopen => fixed

Notes
(0016288)
Luis Ibanez   
2009-05-05 11:07   
Suggested patch:

Index: itkImageConstIterator.h
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/Common/itkImageConstIterator.h,v
retrieving revision 1.23
diff -r1.23 itkImageConstIterator.h
175a176,183
> const RegionType & bufferedRegion = m_Image->GetBufferedRegion();
>
> if( ! bufferedRegion.IsInside( m_Region ) )
> {
> itkGenericExceptionMacro("Region " << m_Region
> << " is outside of buffered region " << bufferedRegion );
> }
>
Index: itkImageConstIteratorWithIndex.txx
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/Common/itkImageConstIteratorWithIndex.txx,v
retrieving revision 1.27
diff -r1.27 itkImageConstIteratorWithIndex.txx
84a85,92
> const RegionType & bufferedRegion = m_Image->GetBufferedRegion();
>
> if( ! bufferedRegion.IsInside( m_Region ) )
> {
> itkGenericExceptionMacro("Region " << m_Region
> << " is outside of buffered region " << bufferedRegion );
> }
>
(0016289)
Luis Ibanez   
2009-05-05 11:17   
Discussion in the ITK Developers list.

http://www.itk.org/mailman/private/insight-developers/2009-May/012427.html [^]
(0022979)
Luis Ibanez   
2010-11-07 01:57   
The following expression is now in itkImageConstIterator.h
lines 175-180:

    if ( region.GetNumberOfPixels() > 0 ) // If region is non-empty
      {
      const RegionType & bufferedRegion = m_Image->GetBufferedRegion();
      itkAssertOrThrowMacro( ( bufferedRegion.IsInside(m_Region) ),
                             "Region " << m_Region << " is outside of buffered region " << bufferedRegion );
      }