Skip to content

Commit

Permalink
Fix crash when snapping to curved geometry without curved segments
Browse files Browse the repository at this point in the history
When a geometry that supports curves has only straight segments and
a user snaps to it with "snap to intersections" enabled, QGIS crashes.

Fixes #33234
  • Loading branch information
m-kuhn committed Oct 13, 2020
1 parent a3d6965 commit a72d84a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/qgspointlocator.cpp
Expand Up @@ -466,8 +466,10 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry *geom, co
for ( auto part = straightGeom.const_parts_begin(); part != straightGeom.const_parts_end(); ++part )
{
// Checking for invalid linestrings
// A linestring should/(must?) have at least two points
if ( qgsgeometry_cast<QgsLineString *>( *part )->numPoints() < 2 )
// A linestring should/(must?) have at least two points.
QgsCurve *curve = qgsgeometry_cast<QgsCurve *>( *part );
Q_ASSERT( !curve->hasCurvedSegments() );
if ( curve->numPoints() < 2 )
continue;

QgsAbstractGeometry::vertex_iterator it = ( *part )->vertices_begin();
Expand Down

0 comments on commit a72d84a

Please sign in to comment.