[Insight-users] Small bug in Examples/IO/DicomSeriesReadPrintTags.cxx

Luis Ibanez luis.ibanez at kitware.com
Sun Sep 17 11:19:08 EDT 2006


Hi Kris,

Thanks for pointing this out.

Following your suggestion, a fix has been committed to CVS.

http://www.itk.org/cgi-bin/viewcvs.cgi/Examples/IO/DicomSeriesReadPrintTags.cxx?rev=1.15&root=Insight&sortby=date&view=log

The diffs are here:

http://www.itk.org/cgi-bin/viewcvs.cgi/Examples/IO/DicomSeriesReadPrintTags.cxx?root=Insight&sortby=date&r2=1.15&r1=1.14


A return statement was added to the first if(), and an else
statement was added to the second.


--


Examples should be bug free, because they are intended to be used
to show users how to use the code. We appreciate your feedback.


Please let us know if you find any other errors in the examples.



     Thanks


        Luis



-----------------------
Kris Thielemans wrote:
> Hi
> 
> There is a small bug in the  Examples/IO/DicomSeriesReadPrintTags.cxx file
> in case an tag is not found. Code goes as follows
> 
>     std::string entryId = "0010|0010";
>     DictionaryType::ConstIterator tagItr = dictionary.Find( entryId );
>     if( tagItr == end )
>       {
>       std::cerr << "Tag " << entryId;
>       std::cerr << " not found in the DICOM header" << std::endl;
>       }
>     MetaDataStringType::ConstPointer entryvalue = 
>       dynamic_cast<const MetaDataStringType *>( tagItr->second.GetPointer()
> );
>     // etc
> 
> This crashes if tagItr==end. There is an 'else' missing as in
>     if( tagItr == end )
>       {
>       std::cerr << "Tag " << entryId;
>       std::cerr << " not found in the DICOM header" << std::endl;
>       }
> 	else
>       {
>       MetaDataStringType::ConstPointer entryvalue = 
>       dynamic_cast<const MetaDataStringType *>( tagItr->second.GetPointer()
> );
>       // etc
>       }
> 
> Ok. This is only an example file, so maybe we don't care. I tend to copy
> stuff from the examples though, so had a bug... I'd suggest to at least flag
> this up in a comment.
> 
> Thanks for all the good work!
> 
> Kris Thielemans
> Hammersmith Imanet, part of GE Healthcare
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 
> 




More information about the Insight-users mailing list