Skip to content

Commit 222f3ad

Browse files
committed
Check for index validity and do not crash!
1 parent bd65fc6 commit 222f3ad

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/core/qgsvectordataprovider.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,12 @@ QVariant QgsVectorDataProvider::maximumValue( int index ) const
426426

427427
QStringList QgsVectorDataProvider::uniqueStringsMatching( int index, const QString &substring, int limit, QgsFeedback *feedback ) const
428428
{
429+
QStringList results;
430+
431+
// Safety belt
432+
if ( index < 0 || index >= fields().count() )
433+
return results;
434+
429435
QgsFeature f;
430436
QgsAttributeList keys;
431437
keys.append( index );
@@ -438,7 +444,6 @@ QStringList QgsVectorDataProvider::uniqueStringsMatching( int index, const QStri
438444
QgsFeatureIterator fi = getFeatures( request );
439445

440446
QSet<QString> set;
441-
QStringList results;
442447

443448
while ( fi.nextFeature( f ) )
444449
{

0 commit comments

Comments
 (0)