Off by one bug in vtkImageExtractComponents
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
In function: void vtkImageExtractComponents::ThreadedExecute() (see http://public.kitware.com/cgi-bin/viewcvs.cgi/Imaging/vtkImageExtractComponents.cxx?rev=1.31&view=markup )
We find the following code:
// make sure we can get all of the components. max = inData->GetNumberOfScalarComponents(); for (idx = 0; idx < this->NumberOfComponents; ++idx) { if (this->Components[idx] > max) { vtkErrorMacro("Execute: Component " << this->Components[idx] << " is not in input."); return; } }
The check on max should be greater than or equal, because if a vtkImageData object has N scalar components, the maximum index is N-1, not N. Also, it might be wise to check for < zero as well.