diff options
| author | Antony Dovgal <tony2001@php.net> | 2008-01-29 00:39:46 +0000 |
|---|---|---|
| committer | Antony Dovgal <tony2001@php.net> | 2008-01-29 00:39:46 +0000 |
| commit | 183ed5b68673ac9bf44774cdb98b38f099678221 (patch) | |
| tree | dec458b5f7c4e74902ab7a0e396bdc6b92e1c85e /ext/standard/array.c | |
| parent | 4252942abd34b07bca9a2daeceb43c90d483d098 (diff) | |
| download | php-git-183ed5b68673ac9bf44774cdb98b38f099678221.tar.gz | |
MFH: fix #43596 (array_slice(): $length arg ignored when it is 0)
Diffstat (limited to 'ext/standard/array.c')
| -rw-r--r-- | ext/standard/array.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index adc7e0f865..a66a9366e5 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2113,12 +2113,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 *z_length; char *string_key; uint string_key_len; ulong num_key; HashPosition hpos; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|lb", &input, &offset, &length, &preserve_keys) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|z/b", &input, &offset, &z_length, &preserve_keys) == FAILURE) { return; } @@ -2126,7 +2127,10 @@ 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 is null */ - if (length == 0) { + if (ZEND_NUM_ARGS() >= 3 && Z_TYPE_P(z_length) != IS_NULL) { + convert_to_long(z_length); + length = Z_LVAL_P(z_length); + } else { length = num_in; } |
