]> granicus.if.org Git - php/commitdiff
Fixed bug #36458 (sleep() accepts negative values).
authorIlia Alshanetsky <iliaa@php.net>
Tue, 21 Feb 2006 15:32:06 +0000 (15:32 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 21 Feb 2006 15:32:06 +0000 (15:32 +0000)
NEWS
ext/standard/basic_functions.c

diff --git a/NEWS b/NEWS
index 3683e747505399255b5d2c5708076b5ee907978c..42f8fba510f75832bc5e2dd062b650a8a353e964 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@ PHP                                                                        NEWS
   (Mike)
 - Fixed tiger hash algorithm generating wrong results on big endian platforms.
   (Mike)
+- Fixed bug #36458 (sleep() accepts negative values). (Ilia)
 - Fixed bug #36436 (DBA problem with Berkeley DB4). (Marcus)
 - Fixed bug #36434 (Improper resolution of declaring class name of an inherited
   property). (Ilia)
index 0c5e614df54acc0df181099b5005a4f5bd95baa8..2ff5bb83f601f9a6099b3d5499fa711f81a33a83 100644 (file)
@@ -1747,17 +1747,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
 
 }