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 committed Jul 20, 2021
1 parent 6776b1b commit 912c0a86b5bf438b496369e11d2db1d540b5f495
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/core/expression/qgsexpressionfunction.cpp
@@ -5520,6 +5520,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();
@@ -5561,6 +5564,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 912c0a8

Please sign in to comment.