summaryrefslogtreecommitdiff
path: root/ext/standard/rand.c
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2010-11-25 16:44:20 +0000
committerGustavo André dos Santos Lopes <cataphract@php.net>2010-11-25 16:44:20 +0000
commit1d5eff07f3a5c1ff74cf9d0660895fb0764d1ead (patch)
tree0cae8b43a7b2c7c2eedaa19b661b90a2d6efd027 /ext/standard/rand.c
parent965c30dc2e74c12ad757ff4e73b9373c7d142a46 (diff)
downloadphp-git-1d5eff07f3a5c1ff74cf9d0660895fb0764d1ead.tar.gz
- Fixed bug #53403 (use of unitialized values). Fixes the fix for bug #46587.
- Added test for bug #46587.
Diffstat (limited to 'ext/standard/rand.c')
-rw-r--r--ext/standard/rand.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/standard/rand.c b/ext/standard/rand.c
index 8cd130d969..5658d3c70c 100644
--- a/ext/standard/rand.c
+++ b/ext/standard/rand.c
@@ -315,18 +315,19 @@ PHP_FUNCTION(mt_rand)
long number;
int argc = ZEND_NUM_ARGS();
- if (argc != 0 && zend_parse_parameters(argc TSRMLS_CC, "ll", &min, &max) == FAILURE)
- return;
+ if (argc != 0) {
+ if (zend_parse_parameters(argc TSRMLS_CC, "ll", &min, &max) == FAILURE) {
+ return;
+ } else if (max < min) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "max(%ld) is smaller than min(%ld)", max, min);
+ RETURN_FALSE;
+ }
+ }
if (!BG(mt_rand_is_seeded)) {
php_mt_srand(GENERATE_SEED() TSRMLS_CC);
}
- if (max < min) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "max(%ld) is smaller than min(%ld)", max, min);
- RETURN_FALSE;
- }
-
/*
* Melo: hmms.. randomMT() returns 32 random bits...
* Yet, the previous php_rand only returns 31 at most.