Skip to content

Commit a6aa855

Browse files
committed
[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
1 parent e3bfec0 commit a6aa855

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/server/qgswfsserver.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,10 @@ QString QgsWFSServer::createFeatureGeoJSON( QgsFeature* feat, int prec, QgsCoord
18971897
for ( int i = 0; i < attrIndexes.count(); ++i )
18981898
{
18991899
int idx = attrIndexes[i];
1900+
if ( idx >= fields->count() )
1901+
{
1902+
continue;
1903+
}
19001904
QString attributeName = fields->at( idx ).name();
19011905
//skip attribute if it is excluded from WFS publication
19021906
if ( excludedAttributes.contains( attributeName ) )
@@ -1992,6 +1996,10 @@ QDomElement QgsWFSServer::createFeatureGML2( QgsFeature* feat, QDomDocument& doc
19921996
for ( int i = 0; i < attrIndexes.count(); ++i )
19931997
{
19941998
int idx = attrIndexes[i];
1999+
if ( idx >= fields->count() )
2000+
{
2001+
continue;
2002+
}
19952003
QString attributeName = fields->at( idx ).name();
19962004
//skip attribute if it is excluded from WFS publication
19972005
if ( excludedAttributes.contains( attributeName ) )
@@ -2065,6 +2073,10 @@ QDomElement QgsWFSServer::createFeatureGML3( QgsFeature* feat, QDomDocument& doc
20652073
for ( int i = 0; i < attrIndexes.count(); ++i )
20662074
{
20672075
int idx = attrIndexes[i];
2076+
if ( idx >= fields->count() )
2077+
{
2078+
continue;
2079+
}
20682080
QString attributeName = fields->at( idx ).name();
20692081
//skip attribute if it is excluded from WFS publication
20702082
if ( excludedAttributes.contains( attributeName ) )

0 commit comments

Comments
 (0)