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 21, 2021
1 parent 13e3d2f commit df0b638b024dc3b0c4a064f25b1f48c35beabaa2
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 df0b638

Please sign in to comment.