diff options
| author | Ilia Alshanetsky <iliaa@php.net> | 2006-02-21 15:32:34 +0000 |
|---|---|---|
| committer | Ilia Alshanetsky <iliaa@php.net> | 2006-02-21 15:32:34 +0000 |
| commit | fca6eecbe944effb6374e63271a008947b266e64 (patch) | |
| tree | b0870fb5a74f80f1cded6135259948254d4558c7 | |
| parent | 53f2048fd14d7c301fad172d74c93d523ce95f2d (diff) | |
| download | php-git-fca6eecbe944effb6374e63271a008947b266e64.tar.gz | |
MFB51: Fixed bug #36458 (sleep() accepts negative values).
| -rw-r--r-- | ext/standard/basic_functions.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index ea54c27967..1738fb9a74 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1677,17 +1677,19 @@ PHP_FUNCTION(flush) Delay for a given number of seconds */ PHP_FUNCTION(sleep) { - zval **num; + long num; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) { + RETURN_FALSE; + } + if (num < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of seconds must be greater than or equal to 0"); + RETURN_FALSE; } - - convert_to_long_ex(num); #ifdef PHP_SLEEP_NON_VOID - RETURN_LONG(php_sleep(Z_LVAL_PP(num))); + RETURN_LONG(php_sleep(num)); #else - php_sleep(Z_LVAL_PP(num)); + php_sleep(num); #endif } |
