Skip to content
Permalink
Browse files

Fix intermittently failing postgres provider test

Provider can crash if features do not have enough attributes
set to match fields in layer.

(cherry-picked from fb3e1c3)
  • Loading branch information
nyalldawson committed Feb 26, 2018
1 parent 90d50ec commit 4f1c100e0cfba6cb24059693f181c709ecde3ff2
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/providers/postgres/qgspostgresprovider.cpp
@@ -2031,7 +2031,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags )
// e.g. for defaults
for ( int idx = 0; idx < attributevec.count(); ++idx )
{
QVariant v = attributevec.at( idx );
QVariant v = attributevec.value( idx, QVariant( QVariant::Int ) ); // default to NULL for missing attributes
if ( fieldId.contains( idx ) )
continue;

@@ -2050,7 +2050,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags )
for ( i = 1; i < flist.size(); i++ )
{
QgsAttributes attrs2 = flist[i].attributes();
QVariant v2 = attrs2.at( idx );
QVariant v2 = attrs2.value( idx, QVariant( QVariant::Int ) ); // default to NULL for missing attributes

if ( v2 != v )
break;

0 comments on commit 4f1c100

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