tony2001 Tue Jan 29 00:39:46 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/standard array.c
Log:
MFH: fix #43596 (array_slice(): $length arg ignored when it is 0)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.17&r2=1.308.2.21.2.37.2.18&diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.17
php-src/ext/standard/array.c:1.308.2.21.2.37.2.18
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.17 Fri Jan 25 15:52:48 2008
+++ php-src/ext/standard/array.c Tue Jan 29 00:39:46 2008
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: array.c,v 1.308.2.21.2.37.2.17 2008/01/25 15:52:48 rrichards Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.18 2008/01/29 00:39:46 tony2001 Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -2113,12 +2113,13 @@
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 @@
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;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php