MantisBT - ITK
View Issue Details
0010025ITKpublic2009-12-10 14:482009-12-16 08:21
Greg Harris 
Hans Johnson 
normalcrashhave not tried
closedfixed 
ITK-3-16 
 
0010025: Review/Statistics/itkScalarImageToHistogramGenerator.txx SetHistogramMin and SetHistogramMax allocate MeasurementVectorType
Review/Statistics/itkScalarImageToHistogramGenerator.txx contains methods for SetHistogramMin and SetHistogramMax that allocate minVector and maxVector with size defaulted to zero instead of like this:

MeasurementVectorType minVector(1);

The result of executing it this way:

MeasurementVectorType minVector;

is a memory fault crash.
cvs diff itkScalarImageToHistogramGenerator.txx
Index: itkScalarImageToHistogramGenerator.txx
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/Review/Statistics/itkScalarImageToHistogramGenerator.txx,v
retrieving revision 1.4
diff -r1.4 itkScalarImageToHistogramGenerator.txx
79c79
< MeasurementVectorType minVector;
---
> MeasurementVectorType minVector(1);
91c91
< MeasurementVectorType maxVector;
---
> MeasurementVectorType maxVector(1);
No tags attached.
Issue History
2009-12-10 14:48Greg HarrisNew Issue
2009-12-10 19:42Bradley LowekampNote Added: 0018807
2009-12-11 08:01Hans JohnsonStatusnew => assigned
2009-12-11 08:01Hans JohnsonAssigned To => Hans Johnson
2009-12-11 08:04Hans JohnsonNote Added: 0018812
2009-12-11 12:04Bradley LowekampNote Added: 0018820
2009-12-16 08:21Hans JohnsonNote Added: 0018912
2009-12-16 08:21Hans JohnsonStatusassigned => resolved
2009-12-16 08:21Hans JohnsonResolutionopen => fixed
2009-12-16 08:21Hans JohnsonStatusresolved => closed

Notes
(0018807)
Bradley Lowekamp   
2009-12-10 19:42   
What PixelType was used for the ImageType provided for the ScalarImageToHistogramGenerator?

This may effect what the MeasurementVectorType is,
(0018812)
Hans Johnson   
2009-12-11 08:04   
Since the name of the class is ScalarImageToHistogramGenerator, I assume that MeasurementVectorType must contain just one element.

A new test was written for nightly regression testing.

Recommended fix was implemented.
(0018820)
Bradley Lowekamp   
2009-12-11 12:04   
Because MeasurementVectors can be a variety of types, which each have different constructors MeasurementVectorTraits have a methods called SetLength. I believe this the the generic and best way to set the correct length of a measurement vector.
(0018912)
Hans Johnson   
2009-12-16 08:21   
This has been fixed and submitted. Thanks to Brad and Luis for suggestions.