mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00
MFB51: Fixed bug #36458 (sleep() accepts negative values).
This commit is contained in:
parent
53f2048fd1
commit
fca6eecbe9
1 changed files with 9 additions and 7 deletions
|
@ -1677,17 +1677,19 @@ PHP_FUNCTION(flush)
|
||||||
Delay for a given number of seconds */
|
Delay for a given number of seconds */
|
||||||
PHP_FUNCTION(sleep)
|
PHP_FUNCTION(sleep)
|
||||||
{
|
{
|
||||||
zval **num;
|
long num;
|
||||||
|
|
||||||
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) {
|
||||||
WRONG_PARAM_COUNT;
|
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
|
#ifdef PHP_SLEEP_NON_VOID
|
||||||
RETURN_LONG(php_sleep(Z_LVAL_PP(num)));
|
RETURN_LONG(php_sleep(num));
|
||||||
#else
|
#else
|
||||||
php_sleep(Z_LVAL_PP(num));
|
php_sleep(num);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue