Skip to content
Permalink
Browse files

Safety check when joining before accessing fields

Fix #9166
  • Loading branch information
m-kuhn committed Dec 5, 2013
1 parent f2fbb2f commit f428c869a980cc707da1fe96e2ba8ba763af78c6
Showing with 7 additions and 0 deletions.
  1. +4 −0 src/core/qgsfield.h
  2. +3 −0 src/core/qgsvectorlayerfeatureiterator.cpp
@@ -196,6 +196,10 @@ class CORE_EXPORT QgsFields
inline int count() const { return mFields.count(); }
//! Return number of items
inline int size() const { return mFields.count(); }
//! Return if a field index is valid
//! @param i Index of the field which needs to be checked
//! @return True if the field exists
inline bool exists( int i ) const { return i >= 0 && i < mFields.count(); }

//! Get field at particular index (must be in range 0..N-1)
inline const QgsField& operator[]( int i ) const { return mFields[i].field; }
@@ -351,6 +351,9 @@ void QgsVectorLayerFeatureIterator::prepareJoins()

for ( QgsAttributeList::const_iterator attIt = fetchAttributes.constBegin(); attIt != fetchAttributes.constEnd(); ++attIt )
{
if ( !fields.exists( *attIt ) )
continue;

if ( fields.fieldOrigin( *attIt ) != QgsFields::OriginJoin )
continue;

0 comments on commit f428c86

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