[vtkusers] missing check in vtkPolyData::ShallowCopy

xabivtk xabivtk at gmail.com
Wed Jul 3 05:04:28 EDT 2013


Hi,
I have a crash when calling ShallowCopy on a vtkPolyData when the polydata
passed as argument is the one that calls the method :
data->ShallowCopy(data)
no question that this call is useless...
but looking into the implementation, there is a comment that says : "I do
not know if this is correct but." for the code that deals with the cells and
links arrays, and this is the place where the crash occurs:

    if (this->Cells)
      {
      this->Cells->UnRegister(this);
      }
    this->Cells = polyData->Cells;
    if (this->Cells)
      {
      this->Cells->Register(this);
      }

the call to this->Cells->UnRegister(this) makes the polyData->Cells to be
destroyed, so this->Cells->Register(this) will crash.

I think a check should be added in the same way as in SetLines, SetPolys,
etc... to verify that the input pointer is not the same as the local one:

if(polyData->Cells != this->Cells)
{
    if (this->Cells)
      {
      this->Cells->UnRegister(this);
      }
    this->Cells = polyData->Cells;
    if (this->Cells)
      {
      this->Cells->Register(this);
      }
...
}

Any comments on that?



--
View this message in context: http://vtk.1045678.n5.nabble.com/missing-check-in-vtkPolyData-ShallowCopy-tp5721741.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list