From 0aed3f715b237dd2cd789b0e0638027d7b5ee00b Mon Sep 17 00:00:00 2001 From: rldhont Date: Fri, 8 Apr 2016 15:26:59 +0200 Subject: [PATCH] [BUGFIX] QGIS Server segfault when features does not have the same fields as the layer. In some WFS GetFeature request, with Filter or FeatureId, all the fields are not well loaded in the feature. To fix it, we just verifying that the attribute index is lesser than the feature fields count. Fixes #14619 --- src/server/qgswfsserver.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/server/qgswfsserver.cpp b/src/server/qgswfsserver.cpp index 3056b41973be..c7031a303a23 100644 --- a/src/server/qgswfsserver.cpp +++ b/src/server/qgswfsserver.cpp @@ -1702,6 +1702,10 @@ QString QgsWFSServer::createFeatureGeoJSON( QgsFeature* feat, int prec, QgsCoord for ( int i = 0; i < attrIndexes.count(); ++i ) { int idx = attrIndexes[i]; + if ( idx >= fields->count() ) + { + continue; + } QString attributeName = fields->at( idx ).name(); //skip attribute if it is excluded from WFS publication if ( excludedAttributes.contains( attributeName ) ) @@ -1783,6 +1787,10 @@ QDomElement QgsWFSServer::createFeatureGML2( QgsFeature* feat, QDomDocument& doc for ( int i = 0; i < attrIndexes.count(); ++i ) { int idx = attrIndexes[i]; + if ( idx >= fields->count() ) + { + continue; + } QString attributeName = fields->at( idx ).name(); //skip attribute if it is excluded from WFS publication if ( excludedAttributes.contains( attributeName ) ) @@ -1842,6 +1850,10 @@ QDomElement QgsWFSServer::createFeatureGML3( QgsFeature* feat, QDomDocument& doc for ( int i = 0; i < attrIndexes.count(); ++i ) { int idx = attrIndexes[i]; + if ( idx >= fields->count() ) + { + continue; + } QString attributeName = fields->at( idx ).name(); //skip attribute if it is excluded from WFS publication if ( excludedAttributes.contains( attributeName ) )