Skip to content

Commit 518072e

Browse files
committed
expression: validate places value of format_number (fixes #12796)
1 parent 239dc71 commit 518072e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/core/qgsexpression.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,11 @@ static QVariant fcnFormatNumber( const QVariantList& values, const QgsFeature*,
13451345
{
13461346
double value = getDoubleValue( values.at( 0 ), parent );
13471347
int places = getIntValue( values.at( 1 ), parent );
1348+
if ( places < 0 )
1349+
{
1350+
parent->setEvalErrorString( QObject::tr( "Number of places must be positive" ) );
1351+
return QVariant();
1352+
}
13481353
return QString( "%L1" ).arg( value, 0, 'f', places );
13491354
}
13501355

0 commit comments

Comments
 (0)