Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
expression: validate places value of format_number (fixes #12796)
(cherry picked from commit 518072e)
  • Loading branch information
jef-n committed Jun 29, 2015
1 parent 8b503a1 commit 9ef8b29
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/qgsexpression.cpp
Expand Up @@ -1345,6 +1345,11 @@ static QVariant fcnFormatNumber( const QVariantList& values, const QgsFeature*,
{
double value = getDoubleValue( values.at( 0 ), parent );
int places = getIntValue( values.at( 1 ), parent );
if ( places < 0 )
{
parent->setEvalErrorString( QObject::tr( "Number of places must be positive" ) );
return QVariant();
}
return QString( "%L1" ).arg( value, 0, 'f', places );
}

Expand Down

0 comments on commit 9ef8b29

Please sign in to comment.