Skip to content
Permalink
Browse files

Fix crash in QgsGeometry::unaryUnion with empty geometries

(cherry-picked from b61641d)
  • Loading branch information
nyalldawson committed Jul 19, 2016
1 parent c105567 commit 0b85f5b8c58c210038d3d819cc522a98f15a6229
Showing with 17 additions and 1 deletion.
  1. +1 −1 src/core/geometry/qgsgeometry.cpp
  2. +16 −0 tests/src/core/testqgsgeometry.cpp
@@ -1618,7 +1618,7 @@ QgsGeometry *QgsGeometry::unaryUnion( const QList<QgsGeometry*> &geometryList )
QList<QgsGeometry*>::const_iterator it = geometryList.constBegin();
for ( ; it != geometryList.constEnd(); ++it )
{
if ( *it )
if ( *it && !(( *it )->isEmpty() ) )
{
geomV2List.append(( *it )->geometry() );
}
@@ -90,6 +90,8 @@ class TestQgsGeometry : public QObject
void bufferCheck();
void smoothCheck();

void unaryUnion();

void dataStream();

void exportToGeoJSON();
@@ -3256,6 +3258,20 @@ void TestQgsGeometry::smoothCheck()
QVERIFY( QgsGeometry::compare( multipoly, expectedMultiPoly ) );
}

void TestQgsGeometry::unaryUnion()
{
//test QgsGeometry::unaryUnion with null geometry
QString wkt1 = "Polygon ((0 0, 10 0, 10 10, 0 10, 0 0 ))";
QString wkt2 = "Polygon ((2 2, 4 2, 4 4, 2 4, 2 2))";
QScopedPointer< QgsGeometry > geom1( QgsGeometry::fromWkt( wkt1 ) );
QScopedPointer< QgsGeometry > geom2( QgsGeometry::fromWkt( wkt2 ) );
QScopedPointer< QgsGeometry > empty( new QgsGeometry() );
QList< QgsGeometry* > list;
list << geom1.data() << empty.data() << geom2.data();

QScopedPointer< QgsGeometry > result( QgsGeometry::unaryUnion( list ) );
}

void TestQgsGeometry::dataStream()
{
QString wkt = "Point (40 50)";

0 comments on commit 0b85f5b

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