[vtk-developers] Handling invalid vtp files

Francois Bertel francois.bertel at kitware.com
Sat Feb 13 18:57:10 EST 2010


That's clearly a bug in  the XMLPolyDataReader.

That's the job of a reader to check if the content of a file is valid.
In this case, it should return an message error.

On Sat, Feb 13, 2010 at 6:42 PM, pat marion <pat.marion at kitware.com> wrote:
> Methods like GetTuple should be fast, and therefore not perform bounds
> checking for each call.  For methods requiring speed, usually it's the
> caller's responsibility to do the bounds checking.  Maybe the proper fix
> would be somewhere higher in the stack like
> vtkPolygon::ComputeNormal or PVGeometryFilter::ExecuteCellNormals?
> Pat
>
> On Sat, Feb 13, 2010 at 6:18 PM, David Doria <daviddoria+vtk at gmail.com>
> wrote:
>>
>> I noticed this problem a while back:
>> http://public.kitware.com/Bug/view.php?id=9814
>> The demo file I added to the bug contains a triangle cell but 0 points.
>> Clearly this is a bad situation. It doesn't crash the XMLPolyDataReader, but
>> if you load the file in Paraview, the call stack shows:
>> vtkDataArrayTemplate<float>::GetTuple (line 613)
>> vtkPoints::GetPoint
>> vtkPolygon::ComputeNormal
>> PVGeometryFilter::ExecuteCellNormals
>> The problem occurs on line 610 of vtkDataArrayTemplate.txx - 't' is NULL,
>> so then on line 613 it segfaults.
>> Is this type of thing where we would want to allow a crash (the assumption
>> being that only good data files are loaded)? Or could we change:
>> template <class T>
>> void vtkDataArrayTemplate<T>::GetTuple(vtkIdType i, double* tuple)
>> {
>>   T* t = this->Array + this->NumberOfComponents*i;
>>   for(int j=0; j < this->NumberOfComponents; ++j)
>>     {
>>     tuple[j] = static_cast<double>(t[j]);
>>     }
>> }
>> to something like:
>> template <class T>
>> void vtkDataArrayTemplate<T>::GetTuple(vtkIdType i, double* tuple)
>> {
>>   T* t = this->Array + this->NumberOfComponents*i;
>>   if(!t)
>>     {
>>     return;
>>     }
>>   for(int j=0; j < this->NumberOfComponents; ++j)
>>     {
>>     tuple[j] = static_cast<double>(t[j]);
>>     }
>> }
>> Thanks,
>>
>> David
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>
>>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
>



-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                      | Clifton Park NY 12065, USA



More information about the vtk-developers mailing list