Skip to content
Permalink
Browse files

Fix potential crash when using default expression parameters

  • Loading branch information
nyalldawson committed Aug 16, 2016
1 parent e3f0d3d commit d008d31f38e9cbf04b1ece84bc862f36847b0e59
Showing with 5 additions and 5 deletions.
  1. +2 −2 src/core/qgsexpression.cpp
  2. +3 −3 src/core/qgsexpression.h
@@ -2514,14 +2514,14 @@ static QVariant fcnShortestLine( const QVariantList& values, const QgsExpression

static QVariant fcnRound( const QVariantList& values, const QgsExpressionContext *, QgsExpression* parent )
{
if ( values.length() == 2 )
if ( values.length() == 2 && values.at( 1 ).toInt() != 0 )
{
double number = getDoubleValue( values.at( 0 ), parent );
double scaler = pow( 10.0, getIntValue( values.at( 1 ), parent ) );
return QVariant( qRound( number * scaler ) / scaler );
}

if ( values.length() == 1 )
if ( values.length() >= 1 )
{
double number = getIntValue( values.at( 0 ), parent );
return QVariant( qRound( number ) );
@@ -951,9 +951,9 @@ class CORE_EXPORT QgsExpression
NodeFunction( int fnIndex, NodeList* args ) : mFnIndex( fnIndex )
{
const ParameterList& functionParams = Functions()[mFnIndex]->parameters();
if ( !args || !args->hasNamedNodes() || functionParams.isEmpty() )
if ( !args || functionParams.isEmpty() )
{
// no named parameters, or function does not support them
// no parameters, or function does not support them
mArgs = args;
}
else
@@ -962,7 +962,7 @@ class CORE_EXPORT QgsExpression

int idx = 0;
//first loop through unnamed arguments
while ( args->names().at( idx ).isEmpty() )
while ( idx < args->names().size() && args->names().at( idx ).isEmpty() )
{
mArgs->append( args->list().at( idx )->clone() );
idx++;

0 comments on commit d008d31

Please sign in to comment.
You can’t perform that action at this time.