]> granicus.if.org Git - php/commitdiff
- Fix the fix for bug #41686
authorJani Taskinen <jani@php.net>
Fri, 2 Nov 2007 11:48:35 +0000 (11:48 +0000)
committerJani Taskinen <jani@php.net>
Fri, 2 Nov 2007 11:48:35 +0000 (11:48 +0000)
ext/standard/array.c

index f72f8aed61704abb3f5da7cb14fd10a3f918f9b2..a54630a5b5b9d94ee80476e8928ea47ca7012937 100644 (file)
@@ -2304,13 +2304,13 @@ PHP_FUNCTION(array_slice)
        zend_bool preserve_keys = 0; /* Whether to preserve keys while copying to the new array or not */
        int              num_in,                /* Number of elements in the input array */
                     pos;                       /* Current position in the array */
+       zval    *lenght_param;
        zstr string_key;
        int string_key_len;
        ulong num_key;
        HashPosition hpos;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|l!b", &input,
-                                                         &offset, &length, &preserve_keys) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|zb", &input, &offset, &length_param, &preserve_keys) == FAILURE) {
                return;
        }
        
@@ -2318,7 +2318,9 @@ PHP_FUNCTION(array_slice)
        num_in = zend_hash_num_elements(Z_ARRVAL_P(input));
        
        /* We want all entries from offset to the end if length is not passed or length is null */
-       if (ZEND_NUM_ARGS() < 3 || length == NULL) {
+       if (ZEND_NUM_ARGS() >= 3 && Z_TYPE_P(length_param) != IS_NULL) {
+               length = Z_LVAL_P(length_param);
+       } else {
                length = num_in;
        }