cvs: php-src(PHP_5_0) / NEWS /ext/standard array.c /ext/standard/tests/array bug34227.phpt

From: Date: Thu, 01 Sep 2005 12:01:02 +0000
Subject: cvs: php-src(PHP_5_0) / NEWS /ext/standard array.c /ext/standard/tests/array bug34227.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-33731@lists.php.net to get a copy of this message
dmitry Thu Sep 1 08:01:02 2005 EDT Added files: (Branch: PHP_5_0) /php-src/ext/standard/tests/array bug34227.phpt Modified files: /php-src NEWS /php-src/ext/standard array.c Log: Fixed bug #34277 (array_filter() crashes with references and objects) http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1760.2.470&r2=1.1760.2.471&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.1760.2.470 php-src/NEWS:1.1760.2.471 --- php-src/NEWS:1.1760.2.470 Tue Aug 30 05:15:56 2005 +++ php-src/NEWS Thu Sep 1 08:01:00 2005 @@ -25,6 +25,8 @@ (Derick) - Fixed bug #34299 (ReflectionClass::isInstantiable() returns true for abstract classes). (Marcus) +- Fixed bug #34277 (array_filter() crashes with references and objects). + (Dmitry) - Fixed bug #34078 (Reflection API problems in methods with boolean or null default values). (Tony) - Fixed bug #34064 (arr[] as param to function is allowed only if function http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.266.2.24&r2=1.266.2.25&ty=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.266.2.24 php-src/ext/standard/array.c:1.266.2.25 --- php-src/ext/standard/array.c:1.266.2.24 Sun Aug 21 14:36:33 2005 +++ php-src/ext/standard/array.c Thu Sep 1 08:01:01 2005 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.266.2.24 2005/08/21 18:36:33 zeev Exp $ */ +/* $Id: array.c,v 1.266.2.25 2005/09/01 12:01:01 dmitry Exp $ */ #include "php.h" #include "php_ini.h" @@ -3975,6 +3975,7 @@ PHP_FUNCTION(array_filter) { zval **input, **callback = NULL; + zval *array; zval **operand; zval **args[1]; zval *retval = NULL; @@ -3994,6 +3995,7 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "The first argument should be an array"); return; } + array = *input; if (ZEND_NUM_ARGS() > 1) { if (!zend_is_callable(*callback, 0, &callback_name)) { @@ -4005,13 +4007,13 @@ } array_init(return_value); - if (zend_hash_num_elements(Z_ARRVAL_PP(input)) == 0) { + if (zend_hash_num_elements(Z_ARRVAL_P(array)) == 0) { return; } - for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(input), &pos); - zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void **)&operand, &pos) == SUCCESS; - zend_hash_move_forward_ex(Z_ARRVAL_PP(input), &pos)) { + for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(array), &pos); + zend_hash_get_current_data_ex(Z_ARRVAL_P(array), (void **)&operand, &pos) == SUCCESS; + zend_hash_move_forward_ex(Z_ARRVAL_P(array), &pos)) { if (callback) { zend_fcall_info fci; @@ -4044,7 +4046,7 @@ } zval_add_ref(operand); - switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(input), &string_key, &string_key_len, &num_key, 0, &pos)) { + switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(array), &string_key, &string_key_len, &num_key, 0, &pos)) { case HASH_KEY_IS_STRING: zend_hash_update(Z_ARRVAL_P(return_value), string_key, string_key_len, operand, sizeof(zval *), NULL); break; http://cvs.php.net/co.php/php-src/ext/standard/tests/array/bug34227.phpt?r=1.1&p=1 Index: php-src/ext/standard/tests/array/bug34227.phpt +++ php-src/ext/standard/tests/array/bug34227.phpt --TEST-- Bug #34277 (array_filter() crashes with references and objects) --FILE-- <?php class C { function m1() { $this->m2(); } function m2() { $this->m3(); } function m3() { $this->m4(); } function m4() { $this->m5(); } function m5() { $this->m6(); } function m6() { $this->m7(); } function m7() { $this->m8(); } function m8() { $this->m9(); } function m9() { $this->m10(); } function m10() { $this->m11(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); } function m11($a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10) { $arr = explode('a', 'b'); } } function f($str) { $obj =& new C; $obj->m1(); return TRUE; } function p5($a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10, $a11, $a12) { $ret = array_filter(array(0), 'f'); } function p4() { p5(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); } function p3() { p4(); } function p2() { p3(); } function p1() { p2(); } p1(); echo "ok\n"; ?> --EXPECT-- ok

« previous php.cvs (#33731) next »