Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 3.10] QgsExpression::referencedAttributeIndexes(): only report valid indices #33958

Merged
merged 3 commits into from Jan 21, 2020

Conversation

rouault
Copy link
Contributor

@rouault rouault commented Jan 21, 2020

Backport of #33927

If the expression was referencing a non-existing field, -1 was returned in the
result set, which caused later crashed in various providers, including the
Spatialite, Postgres, etc..., due to tried to dereference mFields.at(-1)

Discarding invalid indices is what is also done in
QgsFeatureRequest::OrderBy::usedAttributeIndices()

Fixes #33878

If the expression was referencing a non-existing field, -1 was returned in the
result set, which caused later crashed in various providers, including the
Spatialite, Postgres, etc..., due to tried to dereference mFields.at(-1)

Discarding invalid indices is what is also done in
QgsFeatureRequest::OrderBy::usedAttributeIndices()

Fixes qgis#33878
…s to non existing fields in filter expression and order by
…ust to references to non existing fields in filter expression
@rouault rouault added Backport Is a backport of another pull request Bug Either a bug report, or a bug fix. Let's hope for the latter! labels Jan 21, 2020
if ( !mAttributeList.contains( attrIdx ) )
mAttributeList << attrIdx;
}
}

// ensure that all attributes required for order by are fetched
const QSet< QString > orderByAttributes = mRequest.orderBy().usedAttributes();
for ( const QString &attr : orderByAttributes )
const auto orderByAttributes = mRequest.orderBy().usedAttributeIndices( mSource->mFields );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting choice to switch from auto to explicit on line 73 and from explicit to auto here.

@m-kuhn m-kuhn changed the title [Backport 3.10] [BUGFIX] QgsExpression::referencedAttributeIndexes(): only report valid indices [Backport 3.10] QgsExpression::referencedAttributeIndexes(): only report valid indices Jan 21, 2020
@rouault rouault merged commit 2be9fbc into qgis:release-3_10 Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport Is a backport of another pull request Bug Either a bug report, or a bug fix. Let's hope for the latter!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants