mirror of
https://github.com/php/php-src.git
synced 2025-01-27 06:03:45 +08:00
MFH: improve usleep(): use new param parsing API, check for negative values
(related to #36410)
This commit is contained in:
parent
f2ac3274d7
commit
2108714a2b
@ -1766,13 +1766,16 @@ PHP_FUNCTION(sleep)
|
||||
PHP_FUNCTION(usleep)
|
||||
{
|
||||
#if HAVE_USLEEP
|
||||
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;
|
||||
}
|
||||
convert_to_long_ex(num);
|
||||
usleep(Z_LVAL_PP(num));
|
||||
if (num < 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of microseconds must be greater than or equal to 0");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
usleep(num);
|
||||
#endif
|
||||
}
|
||||
/* }}} */
|
||||
|
Loading…
Reference in New Issue
Block a user