Skip to content

Commit

Permalink
safer handling
Browse files Browse the repository at this point in the history
  • Loading branch information
roya0045 committed Nov 13, 2020
1 parent 820f3b9 commit 551d563
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/expression/qgsexpressionfunction.cpp
Expand Up @@ -5324,10 +5324,10 @@ static QVariant fcnArrayGet( const QVariantList &values, const QgsExpressionCont
{
const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
const int pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
if ( pos >= list.length() ) return QVariant();
if ( pos < 0 && ( list.length() + pos ) >= 0 )
if ( pos < list.length() && pos >=0 ) return list.at( pos );
elif ( pos < 0 && ( list.length() + pos ) >= 0 )
return list.at( list.length() + pos );
return list.at( pos );
return QVariant();
}

static QVariant fcnArrayFirst( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
Expand Down

0 comments on commit 551d563

Please sign in to comment.