Skip to content
Permalink
Browse files

Handle integer 64 for QVariant. Fix #36412.

  • Loading branch information
ismailsunni authored and nyalldawson committed May 14, 2020
1 parent aacb31f commit 39cbb33fc15d09fa7c332a186f225b5d4054b308
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/core/expression/qgsexpressionfunction.cpp
@@ -434,6 +434,17 @@ static QVariant fcnRnd( const QVariantList &values, const QgsExpressionContext *
generator.seed( seed );
}

qint64 randomInteger = min + ( generator() % ( max - min + 1 ) );
if ( randomInteger > std::numeric_limits<int>::max() || randomInteger < -std::numeric_limits<int>::max() )
{
return QVariant( randomInteger );
}
else
{
// Prevent wrong conversion of QVariant. See #36412
return QVariant( int( randomInteger ) );
}

// Return a random integer in the range [min, max] (inclusive)
return QVariant( min + ( generator() % ( max - min + 1 ) ) );
}

0 comments on commit 39cbb33

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