Skip to content
Permalink
Browse files

Fix crash with malformed WKT

  • Loading branch information
nyalldawson committed Nov 10, 2015
1 parent 0853076 commit 18744b4123b1803e33928e9c34b6e56cba190779
@@ -173,6 +173,12 @@ bool QgsCurvePolygonV2::fromWkt( const QString& wkt )
}
}

if ( mInteriorRings.isEmpty() )
{
clear();
return false;
}

mExteriorRing = mInteriorRings.first();
mInteriorRings.removeFirst();

@@ -129,7 +129,11 @@ def testReferenceGeometry(self):

#test that geometry can be created from WKT
geom = QgsGeometry.fromWkt(row['wkt'])
assert geom, "WKT conversion {} failed: could not create geom:\n{}\n".format(i + 1, row['wkt'])
if row['valid_wkt']:
assert geom, "WKT conversion {} failed: could not create geom:\n{}\n".format(i + 1, row['wkt'])
else:
assert not geom, "Corrupt WKT {} was incorrectly converted to geometry:\n{}\n".format(i + 1, row['wkt'])
continue

#test exporting to WKT results in expected string
result = geom.exportToWkt()
@@ -97,6 +97,8 @@ Point( 1 2 3 4 ),PointZM( 1 2 3 4 ),1,0,0,0,1,0,0,Point( 1 2 ),1,2,1,2,"4d coord
PointM( 4 5 6 ),PointM ( 4 5 6 ),1,0,0,0,1,0,0,POINT(4 5),4,5,4,5,
PointZ (1 2 3),POINT Z (1 2 3),1,0,0,0,1,0,0,POINT(1 2),1,2,1,2,
PointZM( 7 8 9 10 ),PointZM( 7 8 9 10 ),1,0,0,0,1,0,0,POINT( 7 8 ),7,8,7,8,
Polygon(),,,,,,,,,,,,,,Malformed WKT
Polygon,,,,,,,,,,,,,,Malformed WKT
"Polygon ((0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7 , 5 7, 5 5),(1 1,2 1, 2 2, 1 2, 1 1))","POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5),(1 1,2 1,2 2,1 2,1 1))",15,0,95,52,1,2,0,POINT(4.99473684210526 4.99473684210526),0,0,10,10,
"Polygon ((0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7 , 5 7, 5 5))","POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5))",10,0,96,48,1,1,0,POINT(4.95833333333333 4.95833333333333),0,0,10,10,
"Polygon ((0 0, 10 0, 10 10, 0 10, 0 0))","POLYGON((0 0,10 0,10 10,0 10,0 0))",5,0,100,40,1,0,0,POINT(5 5),0,0,10,10,

0 comments on commit 18744b4

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