Skip to content
Permalink
Browse files
Fix crash in expression array functions on qt6
Calling *std::min_element/max_element on an empty container
leads to a crash
  • Loading branch information
nyalldawson authored and github-actions committed Jul 20, 2021
1 parent 1c3c5cd commit 1099dbd8744187a3245d246cdc16707ff1bead81
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/core/expression/qgsexpressionfunction.cpp
@@ -5501,6 +5501,9 @@ static QVariant fcnArrayMajority( const QVariantList &values, const QgsExpressio
++hash[item];
}
const QList< int > occurrences = hash.values();
if ( occurrences.empty() )
return QVariantList();

const int maxValue = *std::max_element( occurrences.constBegin(), occurrences.constEnd() );

const QString option = values.at( 1 ).toString();
@@ -5542,6 +5545,9 @@ static QVariant fcnArrayMinority( const QVariantList &values, const QgsExpressio
++hash[item];
}
const QList< int > occurrences = hash.values();
if ( occurrences.empty() )
return QVariantList();

const int minValue = *std::min_element( occurrences.constBegin(), occurrences.constEnd() );

const QString option = values.at( 1 ).toString();

0 comments on commit 1099dbd

Please sign in to comment.