[Insight-developers] TransformFileReader endless loop

Bill Lorensen bill.lorensen at gmail.com
Mon Feb 18 09:59:30 EST 2008


Tomas,

Please enter a bug:
http://www.itk.org/Wiki/ITK_Procedure_for_Contributing_Bug_Fixes

Thanks,

Bill

On Mon, Feb 18, 2008 at 8:54 AM, Tomáš Kazmar <Tomash.Kazmar at seznam.cz>
wrote:

> Hi all,
>
>  I think there is a bug in itkTransformFileReader which causes an endless
> loop when the input file does not end with an empty new line. A value
> returned
> from a call to std::string::find() should be checked properly for
> std::string::npos,
> there should be something like the following:
>
>  while ( position < data.size() )
>    {
>    // Find the next string
>    std::string::size_type end = data.find ( "\n", position );
>    if (end == std::string::npos) {
>            end = data.size()-1;
>    }
>    std::string line = trim ( data.substr ( position, end - position ) );
>    position = end+1;
>
> patch:
> 114a115,117
> >     if (end == std::string::npos) {
> >           end = data.size()-1;
> >     }
>
> Another option is to add newline at the end of the buffer before the loop
> starts.
>
> Regards,
> Tomas
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.itk.org/mailman/private/insight-developers/attachments/20080218/a61cf0cf/attachment.html


More information about the Insight-developers mailing list