Fix crash when repairing zero length linestring geometry

Fixes #18077
This commit is contained in:
Nyall Dawson 2018-02-12 12:00:43 +10:00
parent 0eda77661f
commit 5431a2dbae
2 changed files with 4 additions and 1 deletions

View File

@ -716,7 +716,7 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidMultiLine( const GEOSGeometry *gin, QS
int ngeoms = GEOSGetNumGeometries_r( handle, gin ); int ngeoms = GEOSGetNumGeometries_r( handle, gin );
uint32_t nlines_alloc = ngeoms; uint32_t nlines_alloc = ngeoms;
QVector<GEOSGeometry *> lines; QVector<GEOSGeometry *> lines;
QVector<GEOSGeometry *> points( ngeoms ); QVector<GEOSGeometry *> points;
lines.reserve( nlines_alloc ); lines.reserve( nlines_alloc );
points.reserve( ngeoms ); points.reserve( ngeoms );

View File

@ -15984,6 +15984,9 @@ void TestQgsGeometry::makeValid()
// collection with invalid geometries // collection with invalid geometries
geoms << qMakePair( QStringLiteral( "GEOMETRYCOLLECTION(LINESTRING(0 0, 0 0), POLYGON((0 0, 10 10, 10 0, 0 10, 0 0)), LINESTRING(10 0, 10 10))" ), geoms << qMakePair( QStringLiteral( "GEOMETRYCOLLECTION(LINESTRING(0 0, 0 0), POLYGON((0 0, 10 10, 10 0, 0 10, 0 0)), LINESTRING(10 0, 10 10))" ),
QStringLiteral( "GEOMETRYCOLLECTION(POINT(0 0), MULTIPOLYGON(((5 5, 0 0, 0 10, 5 5)),((5 5, 10 10, 10 0, 5 5))), LINESTRING(10 0, 10 10)))" ) ); QStringLiteral( "GEOMETRYCOLLECTION(POINT(0 0), MULTIPOLYGON(((5 5, 0 0, 0 10, 5 5)),((5 5, 10 10, 10 0, 5 5))), LINESTRING(10 0, 10 10)))" ) );
// null line (#18077)
geoms << qMakePair( QStringLiteral( "MultiLineString ((356984.0625 6300089, 356984.0625 6300089))" ),
QStringLiteral( "MultiPoint ((356984.0625 6300089))" ) );
Q_FOREACH ( const InputAndExpectedWktPair &pair, geoms ) Q_FOREACH ( const InputAndExpectedWktPair &pair, geoms )
{ {