Skip to content

Commit

Permalink
expression: validate places value of format_number (fixes #12796)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jun 1, 2015
1 parent 239dc71 commit 518072e
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 518072e

Please sign in to comment.