Skip to content

Commit

Permalink
Merge pull request #2868 from manisandro/next_vertex
Browse files Browse the repository at this point in the history
Fix out of bounds array access if nextVertex is called on empty geometry collection
  • Loading branch information
nyalldawson committed Mar 6, 2016
2 parents 42d8884 + 1e90786 commit c50161d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/geometry/qgsgeometrycollectionv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,10 @@ bool QgsGeometryCollectionV2::nextVertex( QgsVertexId& id, QgsPointV2& vertex )
id.ring = -1;
id.vertex = -1;
}
if ( mGeometries.isEmpty() )
{
return false;
}

QgsAbstractGeometryV2* geom = mGeometries.at( id.part );
if ( geom->nextVertex( id, vertex ) )
Expand Down
4 changes: 4 additions & 0 deletions tests/src/core/testqgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "qgslinestringv2.h"
#include "qgspolygonv2.h"
#include "qgscircularstringv2.h"
#include "qgsgeometrycollectionv2.h"

//qgs unit test utility class
#include "qgsrenderchecker.h"
Expand Down Expand Up @@ -360,6 +361,9 @@ void TestQgsGeometry::isEmpty()

geom.setGeometry( 0 );
QVERIFY( geom.isEmpty() );

QgsGeometryCollectionV2 collection;
QVERIFY( collection.isEmpty() );
}

void TestQgsGeometry::pointV2()
Expand Down

0 comments on commit c50161d

Please sign in to comment.