Skip to content

Commit

Permalink
Fix crash using QgsGeometryCollection::vertexAt with empty geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
agiudiceandrea authored and nyalldawson committed Apr 18, 2023
1 parent e5a9b26 commit ffbb8f4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/core/geometry/qgsgeometrycollection.cpp
Expand Up @@ -898,7 +898,18 @@ int QgsGeometryCollection::partCount() const

QgsPoint QgsGeometryCollection::vertexAt( QgsVertexId id ) const
{
return mGeometries[id.part]->vertexAt( id );
if ( id.part < 0 || id.part >= mGeometries.size() )
{
return QgsPoint();
}

const QgsAbstractGeometry *geom = mGeometries[id.part];
if ( !geom )
{
return QgsPoint();
}

return geom->vertexAt( id );
}

bool QgsGeometryCollection::isValid( QString &error, Qgis::GeometryValidityFlags flags ) const
Expand Down

0 comments on commit ffbb8f4

Please sign in to comment.