Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix crash on malformed WKT strings
  • Loading branch information
nyalldawson committed Nov 6, 2015
1 parent 12e34f2 commit fccf54b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/geometry/qgsgeometryutils.cpp
Expand Up @@ -498,11 +498,11 @@ QList<QgsPointV2> QgsGeometryUtils::pointsFromWKT( const QString &wktCoordinateL
double y = coordinates[idx++].toDouble();

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

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

QgsWKBTypes::Type t = QgsWKBTypes::Point;
Expand Down
1 change: 1 addition & 0 deletions tests/testdata/geom_data.csv
Expand Up @@ -50,6 +50,7 @@ GeometryCollection (PointZ (1 2 3)),GEOMETRYCOLLECTION Z (POINT Z (1 2 3)),1,0,0
"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,
"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"
"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"
"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
"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,
"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,
"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,
Expand Down

0 comments on commit fccf54b

Please sign in to comment.