Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f1a0cc8

Browse files
agiudiceandreagithub-actions[bot]
authored andcommittedApr 17, 2023
Fix crash using QgsGeometryCollection::vertexAt with empty geometry
1 parent 2be4178 commit f1a0cc8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed
 

‎src/core/geometry/qgsgeometrycollection.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,18 @@ int QgsGeometryCollection::partCount() const
898898

899899
QgsPoint QgsGeometryCollection::vertexAt( QgsVertexId id ) const
900900
{
901-
return mGeometries[id.part]->vertexAt( id );
901+
if ( id.part < 0 || id.part >= mGeometries.size() )
902+
{
903+
return QgsPoint();
904+
}
905+
906+
const QgsAbstractGeometry *geom = mGeometries[id.part];
907+
if ( !geom )
908+
{
909+
return QgsPoint();
910+
}
911+
912+
return geom->vertexAt( id );
902913
}
903914

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

0 commit comments

Comments
 (0)
Please sign in to comment.