Skip to content

Fix vtkPolyData::GetCell() crash

Andras Lasso requested to merge lassoan/vtk:fix-getcell-crash into master

vtkPolyData::GetCell() crashed the application if any of a cell in a polydata contained less points than expected.

Details: There was a very strict check in vtkPolyData::BuildCells() that cleared out vtkPolyData::Cells when the number of points in any of the cells in a polydata was less than expected. Since vtkPolyData::GetCell() assumes that vtkPolyData::BuildCells() creates a valid vtkPolyData::Cells object, when that strict check failed, vtkPolyData::GetCell() crashed.

The crash could be fixed by an additional null-pointer checks at every use of vtkPolyData::Cells. However, it has been valid to store less than 2 points in a VTK_POLY_LINE cell for decades. Very complex algorithms have been built, relying on this feature. This feature cannot be just suddenly taken away, because it is extremely difficult to rework large computational geometry algorithms to take into account this new constraint.

Note that the diff looks complicated (it seems that gitlab's diff cannot deal very well with indentation changes), but the change is actually very simple: remove the unnecessary point count checks in vtkPolyData::BuildCells().

Edited by Jean-Christophe Fillion-Robin

Merge request reports