Skip to content
Permalink
Browse files

[mssql] Fix crash when requesting min/max/unique values from invalid …

…field index
  • Loading branch information
nyalldawson committed Oct 5, 2018
1 parent a6ae6c1 commit 4986d432474ba47030d567700e84a4e25d310e31
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/providers/mssql/qgsmssqlprovider.cpp
@@ -573,6 +573,11 @@ QString QgsMssqlProvider::storageType() const
// Returns the minimum value of an attribute
QVariant QgsMssqlProvider::minimumValue( int index ) const
{
if ( index < 0 || index >= mAttributeFields.count() )
{
return QVariant();
}

// get the field name
QgsField fld = mAttributeFields.at( index );
QString sql = QStringLiteral( "select min([%1]) from " )
@@ -605,6 +610,11 @@ QVariant QgsMssqlProvider::minimumValue( int index ) const
// Returns the maximum value of an attribute
QVariant QgsMssqlProvider::maximumValue( int index ) const
{
if ( index < 0 || index >= mAttributeFields.count() )
{
return QVariant();
}

// get the field name
QgsField fld = mAttributeFields.at( index );
QString sql = QStringLiteral( "select max([%1]) from " )
@@ -637,6 +647,10 @@ QVariant QgsMssqlProvider::maximumValue( int index ) const
QSet<QVariant> QgsMssqlProvider::uniqueValues( int index, int limit ) const
{
QSet<QVariant> uniqueValues;
if ( index < 0 || index >= mAttributeFields.count() )
{
return uniqueValues;
}

// get the field name
QgsField fld = mAttributeFields.at( index );

0 comments on commit 4986d43

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