Skip to content

Commit c50161d

Browse files
committedMar 6, 2016
Merge pull request #2868 from manisandro/next_vertex
Fix out of bounds array access if nextVertex is called on empty geometry collection
2 parents 42d8884 + 1e90786 commit c50161d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed
 

‎src/core/geometry/qgsgeometrycollectionv2.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ bool QgsGeometryCollectionV2::nextVertex( QgsVertexId& id, QgsPointV2& vertex )
374374
id.ring = -1;
375375
id.vertex = -1;
376376
}
377+
if ( mGeometries.isEmpty() )
378+
{
379+
return false;
380+
}
377381

378382
QgsAbstractGeometryV2* geom = mGeometries.at( id.part );
379383
if ( geom->nextVertex( id, vertex ) )

‎tests/src/core/testqgsgeometry.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "qgslinestringv2.h"
3535
#include "qgspolygonv2.h"
3636
#include "qgscircularstringv2.h"
37+
#include "qgsgeometrycollectionv2.h"
3738

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

361362
geom.setGeometry( 0 );
362363
QVERIFY( geom.isEmpty() );
364+
365+
QgsGeometryCollectionV2 collection;
366+
QVERIFY( collection.isEmpty() );
363367
}
364368

365369
void TestQgsGeometry::pointV2()

0 commit comments

Comments
 (0)
Please sign in to comment.