@@ -91,6 +91,8 @@ class TestQgsGeometry : public QObject
91
91
92
92
void exportToGeoJSON ();
93
93
94
+ void wkbInOut ();
95
+
94
96
private:
95
97
/* * A helper method to do a render check to see if the geometry op is as expected */
96
98
bool renderCheck ( const QString& theTestName, const QString& theComment = " " , int mismatchCount = 0 );
@@ -101,6 +103,24 @@ class TestQgsGeometry : public QObject
101
103
/* * A helper method to dump to qdebug the geometry of a polyline */
102
104
void dumpPolyline ( QgsPolyline &thePolyline );
103
105
106
+ // Release return with delete []
107
+ unsigned char * hex2bytes ( const char *hex, int *size )
108
+ {
109
+ QByteArray ba = QByteArray::fromHex ( hex );
110
+ unsigned char *out = new unsigned char [ba.size ()];
111
+ memcpy ( out, ba.data (), ba.size () );
112
+ *size = ba.size ();
113
+ return out;
114
+ }
115
+
116
+ QString bytes2hex ( const unsigned char *bytes, int size )
117
+ {
118
+ QByteArray ba (( const char * )bytes, size );
119
+ QString out = ba.toHex ();
120
+ return out;
121
+ }
122
+
123
+
104
124
QString elemToString ( const QDomElement& elem ) const ;
105
125
106
126
QgsPoint mPoint1 ;
@@ -3365,5 +3385,23 @@ QString TestQgsGeometry::elemToString( const QDomElement& elem ) const
3365
3385
return s;
3366
3386
}
3367
3387
3388
+ void TestQgsGeometry::wkbInOut ()
3389
+ {
3390
+ // Premature end of WKB
3391
+ // See http://hub.qgis.org/issues/14182
3392
+ const char *hexwkb = " 0102000000EF0000000000000000000000000000000000000000000000000000000000000000000000" ;
3393
+ int size;
3394
+ unsigned char *wkb = hex2bytes ( hexwkb, &size );
3395
+ QgsGeometry g14182;
3396
+ // NOTE: wkb onwership transferred to QgsGeometry
3397
+ g14182.fromWkb ( wkb, size );
3398
+ // QList<QgsGeometry::Error> errors;
3399
+ // g14182.validateGeometry(errors);
3400
+ // Check with valgrind !
3401
+ QString wkt = g14182.exportToWkt ();
3402
+ QCOMPARE ( wkt, QString () );
3403
+
3404
+ }
3405
+
3368
3406
QTEST_MAIN ( TestQgsGeometry )
3369
3407
#include " testqgsgeometry.moc"
0 commit comments