MantisBT - VTK
View Issue Details
0008772VTK(No Category)public2009-03-20 13:322013-04-05 19:57
Simon Warfield 
Bill Lorensen 
normalcrashalways
closedfixed 
 
 
0008772: vtkImageData doesn't use vtkIdType when it should

A variable of type int is used to hold values that can be in the range of vtkIdType and the int overflows for large images, causing processing of large images to fail.

All the occurrences of
int idx;
  in vtkImageData.cxx
should be changed to be
vtkIdType idx;



//----------------------------------------------------------------------------
// This Method returns a pointer to a location in the vtkImageData.
// Coordinates are in pixel units and are relative to the whole
// image origin.
void *vtkImageData::GetArrayPointer(vtkDataArray* array, int coordinate[3])
{
  vtkIdType incs[3];
  int idx;

...

The idx calculation below can overflow, since idx is an int, not a vtkIdType.


  // compute the index of the vector.
  this->GetArrayIncrements(array, incs);
  idx = ((coordinate[0] - extent[0]) * incs[0]
         + (coordinate[1] - extent[2]) * incs[1]
         + (coordinate[2] - extent[4]) * incs[2]);
  // I could check to see if the array has the correct number
  // of tuples for the extent, but that would be an extra multiply.
  if (idx < 0 || idx > array->GetMaxId())
    {
    vtkErrorMacro("Coordinate (" << coordinate[0] << ", " << coordinate[1]
                  << ", " << coordinate[2] << ") out side of array (max = "
                  << array->GetMaxId());
    return NULL;
    }

  return array->GetVoidPointer(idx);
No tags attached.
Issue History
2009-03-20 13:32Simon WarfieldNew Issue
2009-08-17 22:51Simon WarfieldNote Added: 0017150
2009-09-11 19:26Bill LorensenNote Added: 0017399
2009-09-11 19:26Bill LorensenStatusbacklog => @80@
2009-09-11 19:26Bill LorensenResolutionopen => fixed
2009-09-11 19:26Bill LorensenAssigned To => Bill Lorensen
2011-06-16 13:11Zack GalbreathCategory => (No Category)
2013-04-05 19:57Berk GeveciStatuscustomer review => closed

Notes
(0017150)
Simon Warfield   
2009-08-17 22:51   
array->GetMaxId() returns a variable of type vtkIdType, but idx is defined as an int.
This type incompatibility should be fixed by defining idx with
vtkIdType idx;
  instead of
int idx;
  on line 2081
(0017399)
Bill Lorensen   
2009-09-11 19:26   
Made changes suggested by reporter.

http://public.kitware.com/cgi-bin/viewcvs.cgi/Filtering/vtkImageData.cxx?r1=1.34&r2=1.35&sortby=date [^]