Skip to content

Commit 39cbb33

Browse files
ismailsunninyalldawson
authored andcommittedMay 17, 2020
Handle integer 64 for QVariant. Fix #36412.
1 parent aacb31f commit 39cbb33

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
 

‎src/core/expression/qgsexpressionfunction.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,17 @@ static QVariant fcnRnd( const QVariantList &values, const QgsExpressionContext *
434434
generator.seed( seed );
435435
}
436436

437+
qint64 randomInteger = min + ( generator() % ( max - min + 1 ) );
438+
if ( randomInteger > std::numeric_limits<int>::max() || randomInteger < -std::numeric_limits<int>::max() )
439+
{
440+
return QVariant( randomInteger );
441+
}
442+
else
443+
{
444+
// Prevent wrong conversion of QVariant. See #36412
445+
return QVariant( int( randomInteger ) );
446+
}
447+
437448
// Return a random integer in the range [min, max] (inclusive)
438449
return QVariant( min + ( generator() % ( max - min + 1 ) ) );
439450
}

0 commit comments

Comments
 (0)
Please sign in to comment.