Skip to content
Permalink
Browse files

QgsGmlStreamingParser: fix memory leak if parsing a GML file truncate…

…d in the middle of a feature
  • Loading branch information
rouault committed Jun 10, 2016
1 parent 5acb128 commit a4f151131b5261efbe69883233c4a9d4d1824cb7
Showing with 20 additions and 0 deletions.
  1. +2 −0 src/core/qgsgml.cpp
  2. +18 −0 tests/src/core/testqgsgml.cpp
@@ -411,6 +411,8 @@ QgsGmlStreamingParser::~QgsGmlStreamingParser()
{
delete featPair.first;
}

delete mCurrentFeature;
}

bool QgsGmlStreamingParser::processData( const QByteArray& data, bool atEnd )
@@ -72,6 +72,7 @@ class TestQgsGML : public QObject
void testTuple();
void testRenamedFields();
void testTruncatedResponse();
void testPartialFeature();
};

const QString data1( "<myns:FeatureCollection "
@@ -1008,5 +1009,22 @@ void TestQgsGML::testTruncatedResponse()
QCOMPARE( gmlParser.isTruncatedResponse(), true );
}

void TestQgsGML::testPartialFeature()
{
QgsFields fields;
QgsGmlStreamingParser gmlParser( "mytypename", "mygeom", fields );
QCOMPARE( gmlParser.processData( QByteArray( "<myns:FeatureCollection "
"xmlns:myns='http://myns' "
"xmlns:gml='http://www.opengis.net/gml'>"
"<gml:featureMember>"
"<myns:mytypename fid='mytypename.1'>"
"<myns:mygeom>"
"<gml:Point srsName='EPSG:27700'>"
"<gml:coordinates>10,20</gml:coordinates>"
), true ), false );
QVector<QgsGmlStreamingParser::QgsGmlFeaturePtrGmlIdPair> features = gmlParser.getAndStealReadyFeatures();
QCOMPARE( features.size(), 0 );
}

QTEST_MAIN( TestQgsGML )
#include "testqgsgml.moc"

0 comments on commit a4f1511

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