Skip to content

Commit

Permalink
BUG: Fix crash in vtkPointLocator when markups curve polydata is empty
Browse files Browse the repository at this point in the history
In some situations (such as between Start/EndModify calls on vtkMRMLMarkupsCurveNode), it is possible that the output curve polydata will be in a state it has no points.

If TransformedCurvePolyLocator had been previously initialized and FindClosestPoint is called when the curve polydata has no points, then it will cause a crash.
This is due to the vtkPointLocator HashTable not being reset correctly.
See related MR fixing the issue in VTK here: https://gitlab.kitware.com/vtk/vtk/-/merge_requests/11114

This commit fixes the crash by returning if there are no points without checking the vtkPointLocator. This change also serves as an minor optimization.
  • Loading branch information
Sunderlandkyl authored and lassoan committed May 10, 2024
1 parent 10ae009 commit 3a008b9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Modules/Loadable/Markups/MRML/vtkMRMLMarkupsCurveNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ bool vtkMRMLMarkupsCurveNode::GetSampledCurvePointsBetweenStartEndPointsWorld(vt
vtkIdType vtkMRMLMarkupsCurveNode::GetClosestCurvePointIndexToPositionWorld(const double posWorld[3])
{
vtkPoints* points = this->GetCurvePointsWorld();
if (!points)
if (!points || points->GetNumberOfPoints() == 0)
{
return -1;
}
Expand Down

0 comments on commit 3a008b9

Please sign in to comment.