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 acc768e commit 80855d0fdaf4de2a763480c78164dd8cf2f75a1e
Showing with 17 additions and 1 deletion.
  1. +1 −1 src/core/geometry/qgsgeometry.cpp
  2. +16 −0 tests/src/core/testqgsgeometry.cpp
@@ -1596,7 +1596,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() );
}
@@ -88,6 +88,8 @@ class TestQgsGeometry : public QObject
void bufferCheck();
void smoothCheck();

void unaryUnion();

void dataStream();

void exportToGeoJSON();
@@ -3240,6 +3242,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 80855d0

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