Skip to content
Permalink
Browse files

Fix crash on malformed WKT strings

(cherry-picked from fccf54b)
  • Loading branch information
nyalldawson committed Nov 18, 2015
1 parent 54f13a6 commit 799655f4391d810ce4152cdbf8f5fa32f34ef029
Showing with 3 additions and 2 deletions.
  1. +2 −2 src/core/geometry/qgsgeometryutils.cpp
  2. +1 −0 tests/testdata/geom_data.csv
@@ -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;
@@ -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,

0 comments on commit 799655f

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