Skip to content

Commit 799655f

Browse files
committed
Fix crash on malformed WKT strings
(cherry-picked from fccf54b)
1 parent 54f13a6 commit 799655f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/core/geometry/qgsgeometryutils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,11 @@ QList<QgsPointV2> QgsGeometryUtils::pointsFromWKT( const QString &wktCoordinateL
498498
double y = coordinates[idx++].toDouble();
499499

500500
double z = 0;
501-
if (( is3D || foundZ ) && coordinates.length() >= idx )
501+
if (( is3D || foundZ ) && coordinates.length() > idx )
502502
z = coordinates[idx++].toDouble();
503503

504504
double m = 0;
505-
if (( isMeasure || foundM ) && coordinates.length() >= idx )
505+
if (( isMeasure || foundM ) && coordinates.length() > idx )
506506
m = coordinates[idx++].toDouble();
507507

508508
QgsWKBTypes::Type t = QgsWKBTypes::Point;

tests/testdata/geom_data.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ GeometryCollection (PointZ (1 2 3)),GEOMETRYCOLLECTION Z (POINT Z (1 2 3)),1,0,0
5050
"LineString M (1 2 3 , 4 5 6 , 7 8 9 , 10 11 12, 13 14 15)","LINESTRING M (1 2 3,4 5 6,7 8 9,10 11 12,13 14 15)",5,16.9705627485,0,0,1,0,0,POINT(7 8),1,2,13,14,
5151
"LineString( 1 2 3, 4 5 6 )","LineStringZ( 1 2 3, 4 5 6 )",2,4.2426406871,0,0,1,0,0,Point (2.5 3.5),1,2,4,5,"z coordinate, but geometry not explicitly marked as such. Should be upgraded to have Z dimension"
5252
"LineString( 1 2 3 4, 5 6 7 8 )","LineStringZM( 1 2 3 4, 5 6 7 8)",2,5.6568542495,0,0,0,0,0,POINT( 3 4 ),1,2,5,6,"4d coordinates, but geometry not explicitly marked as such. Should be upgraded to have ZM dimension"
53+
"LineString( 1 2 3 4, 5 6 )","LineStringZM( 1 2 3 4, 5 6 0 0)",2,5.6568542495,0,0,0,0,0,POINT( 3 4 ),1,2,5,6,Malformed WKT
5354
"LineString(1 2,2 3,3 4)","LINESTRING(1 2,2 3,3 4)",3,2.8284271247,0,0,1,0,0,POINT(2 3),1,2,3,4,
5455
"LineStringZ (0 0 0 , 1 1 1 , 2 2 2 , 3 3 3, 4 4 4)","LINESTRING Z (0 0 0,1 1 1,2 2 2,3 3 3,4 4 4)",5,5.6568542495,0,0,1,0,0,POINT(2 2),0,0,4,4,
5556
"LineStringZM (0 0 0 2 , 1 1 1 3 , 2 2 2 4, 3 3 3 5, 4 4 4 6)","LineStringZM (0 0 0 2, 1 1 1 3, 2 2 2 4, 3 3 3 5, 4 4 4 6)",5,5.6568542495,0,0,1,0,0,POINT(2 2),0,0,4,4,

0 commit comments

Comments
 (0)