diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2010-11-23 13:09:15 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2010-11-23 13:09:15 +0000 |
commit | 4f3ab10786809cf720c81c8ad29aa6eaacc8ae0a (patch) | |
tree | c0b3037792d44cf6dcf3708c41bba32b070515ed | |
parent | 8ed386997f67b3f2187a7cffc04519f252f5733e (diff) | |
download | php-git-4f3ab10786809cf720c81c8ad29aa6eaacc8ae0a.tar.gz |
Fixed bug #46587 (mt_rand() does not check that max is greater than min).
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | ext/standard/rand.c | 5 |
2 files changed, 7 insertions, 0 deletions
@@ -9,6 +9,8 @@ EXTR_OVERWRITE. (jorto at redhat dot com) . Fixed bug #47168 (printf of floating point variable prints maximum of 40 decimal places). (Ilia) + . Fixed bug #46587 (mt_rand() does not check that max is greater than min). + (Ilia) - Intl extension: . Fixed crashes on invalid parameters in intl extension (Stas, Maksymilian diff --git a/ext/standard/rand.c b/ext/standard/rand.c index 4f1f18b278..eb26cc5c50 100644 --- a/ext/standard/rand.c +++ b/ext/standard/rand.c @@ -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. |