Fix an array out of bounds access when committing data (#3807)

This fixes an array out of bounds access when using a layer that consists of a main table with joined in attributes.
The provider only tracks the attributes in the main table, but any joined in attributes is also passed to the provider.
As the feature attributes is used to govern loop access, there will be an out of bounds access when the first joint
attribute is encountered.

The fix is borrowed from the postgres provider which stops looping through the passed in feature attributes when
the limit of table attributes has been met.
This commit is contained in:
Andreas 2016-12-11 16:49:52 +13:00 committed by Nathan Woodrow
parent 91b03a9c9f
commit 6eb330e2b2

View File

@ -818,6 +818,9 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
for ( int i = 0; i < attrs.count(); ++i )
{
if ( i >= mAttributeFields.count() )
break;
QgsField fld = mAttributeFields.at( i );
if ( fld.typeName().endsWith( QLatin1String( " identity" ), Qt::CaseInsensitive ) )
@ -889,6 +892,9 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
for ( int i = 0; i < attrs.count(); ++i )
{
if ( i >= mAttributeFields.count() )
break;
QgsField fld = mAttributeFields.at( i );
if ( fld.typeName().endsWith( QLatin1String( " identity" ), Qt::CaseInsensitive ) )