Skip to content
Permalink
Browse files

[Bugfix][Server][WFS] Segfault when converting geom to multi

Following 55928c0, [Bugfix][Server][WFS] In GML geometry has all to be multi, in which to avoid memory leak, I don't use a pointer but convertToMuli segfaults in this case.

@nyalldawson has mentioned in the PR #8243 to ignore is comment about pointer, what I missed. So the code has segfaulting.

This commit fixed it by using point and delete it.
  • Loading branch information
rldhont committed Oct 25, 2018
1 parent 75a170d commit 81f4bdbe88d9c383fac81c86cb518d3d5f8b0918
Showing with 9 additions and 8 deletions.
  1. +9 −8 src/server/qgswfsserver.cpp
@@ -2070,12 +2070,11 @@ QDomElement QgsWFSServer::createFeatureGML2( QgsFeature* feat, QDomDocument& doc
typeNameElement.setAttribute( "fid", mTypeName + "." + gmlId );
featureElement.appendChild( typeNameElement );

const QgsGeometry* geom = feat->constGeometry();
const QgsGeometry* cGeom = feat->constGeometry();
QgsGeometry *geom = new QgsGeometry( *cGeom );
if ( isMultiGeom && QgsWKBTypes::isSingleType( QGis::fromOldWkbType( geom->wkbType() ) ) )
{
QgsGeometry cloneGeom( *geom );
cloneGeom.convertToMultiType();
geom = &cloneGeom;
geom->convertToMultiType();
}
if ( geom && mWithGeom && mGeometryName != "NONE" )
{
@@ -2121,6 +2120,7 @@ QDomElement QgsWFSServer::createFeatureGML2( QgsFeature* feat, QDomDocument& doc
typeNameElement.appendChild( geomElem );
}
}
delete geom;

//read all attribute values from the feature
QgsAttributes featureAttributes = feat->attributes();
@@ -2160,12 +2160,12 @@ QDomElement QgsWFSServer::createFeatureGML3( QgsFeature* feat, QDomDocument& doc
typeNameElement.setAttribute( "gml:id", mTypeName + "." + gmlId );
featureElement.appendChild( typeNameElement );

const QgsGeometry* geom = feat->constGeometry();

const QgsGeometry* cGeom = feat->constGeometry();
QgsGeometry *geom = new QgsGeometry( *cGeom );
if ( isMultiGeom && QgsWKBTypes::isSingleType( QGis::fromOldWkbType( geom->wkbType() ) ) )
{
QgsGeometry cloneGeom( *geom );
cloneGeom.convertToMultiType();
geom = &cloneGeom;
geom->convertToMultiType();
}
if ( geom && mWithGeom && mGeometryName != "NONE" )
{
@@ -2211,6 +2211,7 @@ QDomElement QgsWFSServer::createFeatureGML3( QgsFeature* feat, QDomDocument& doc
typeNameElement.appendChild( geomElem );
}
}
delete geom;

//read all attribute values from the feature
QgsAttributes featureAttributes = feat->attributes();

0 comments on commit 81f4bdb

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