mirror of
https://github.com/php/php-src.git
synced 2026-04-18 13:31:27 +02:00
Fixed bug #46587 (mt_rand() does not check that max is greater than min).
This commit is contained in:
@@ -322,6 +322,11 @@ PHP_FUNCTION(mt_rand)
|
||||
php_mt_srand(GENERATE_SEED() TSRMLS_CC);
|
||||
}
|
||||
|
||||
if (max < min) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "max(%d) is smaller than min(%d)", max, min);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Melo: hmms.. randomMT() returns 32 random bits...
|
||||
* Yet, the previous php_rand only returns 31 at most.
|
||||
|
||||
Reference in New Issue
Block a user