Skip to content
Permalink
Browse files

Fix crash when snapping to curved geometry without curved segments

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 a72d84a6413ed7a89192cf1a91755fe01cdd9d10
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/core/qgspointlocator.cpp
@@ -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();

0 comments on commit a72d84a

Please sign in to comment.
You can’t perform that action at this time.