Skip to content

Commit

Permalink
QgsGmlStreamingParser: fix memory leak if parsing a GML file truncate…
Browse files Browse the repository at this point in the history
…d in the middle of a feature
  • Loading branch information
rouault committed Jun 10, 2016
1 parent 5acb128 commit a4f1511
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/qgsgml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ QgsGmlStreamingParser::~QgsGmlStreamingParser()
{
delete featPair.first;
}

delete mCurrentFeature;
}

bool QgsGmlStreamingParser::processData( const QByteArray& data, bool atEnd )
Expand Down
18 changes: 18 additions & 0 deletions tests/src/core/testqgsgml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class TestQgsGML : public QObject
void testTuple();
void testRenamedFields();
void testTruncatedResponse();
void testPartialFeature();
};

const QString data1( "<myns:FeatureCollection "
Expand Down Expand Up @@ -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.