diff options
author | Antony Dovgal <tony2001@php.net> | 2006-02-16 10:13:52 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2006-02-16 10:13:52 +0000 |
commit | 2108714a2b78fa9ef5410c4933534867b940f19d (patch) | |
tree | 021350146390b6a9677f9678bd438be6fde26050 | |
parent | f2ac3274d7a06856c5c5c424ba5fd51e647ab9c1 (diff) | |
download | php-git-2108714a2b78fa9ef5410c4933534867b940f19d.tar.gz |
MFH: improve usleep(): use new param parsing API, check for negative values
(related to #36410)
-rw-r--r-- | ext/standard/basic_functions.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 0506aedefe..90e52db813 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -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 } /* }}} */ |