Skip to content

Commit e32930d

Browse files
committed
[spatialite] Fix crash with a subset of attributes request for joined field
1 parent 5e14fea commit e32930d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/providers/spatialite/qgsspatialitefeatureiterator.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,19 @@ bool QgsSpatiaLiteFeatureIterator::getFeature( sqlite3_stmt *stmt, QgsFeature &f
321321
}
322322
else
323323
{
324-
int attrIndex = subsetAttributes ? mRequest.subsetOfAttributes()[ic-1] : ic - 1;
325-
feature.setAttribute( attrIndex, getFeatureAttribute( stmt, ic, P->attributeFields[attrIndex].type() ) );
324+
if ( subsetAttributes )
325+
{
326+
if ( mRequest.subsetOfAttributes().contains( ic - 1 ) )
327+
{
328+
int attrIndex = mRequest.subsetOfAttributes()[ic-1];
329+
feature.setAttribute( attrIndex, getFeatureAttribute( stmt, ic, P->attributeFields[attrIndex].type() ) );
330+
}
331+
}
332+
else
333+
{
334+
int attrIndex = subsetAttributes ? mRequest.subsetOfAttributes()[ic-1] : ic - 1;
335+
feature.setAttribute( attrIndex, getFeatureAttribute( stmt, ic, P->attributeFields[attrIndex].type() ) );
336+
}
326337
}
327338
}
328339

0 commit comments

Comments
 (0)