[vtkusers] missing check in vtkPolyData::ShallowCopy

Sebastien Jourdain sebastien.jourdain at kitware.com
Wed Jul 3 08:16:19 EDT 2013


I'd rather see at the top of the method

if(this == polyData) return;


On Wed, Jul 3, 2013 at 5:04 AM, xabivtk <xabivtk at gmail.com> wrote:

> 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.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130703/6cb08525/attachment.htm>


More information about the vtkusers mailing list