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

From: Date: Sat, 27 Dec 2008 03:07:46 +0000
Subject: cvs: php-src(PHP_5_2) / NEWS /ext/standard array.c /ext/standard/tests/array bug46873.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-55133@lists.php.net to get a copy of this message
lbarnaud Sat Dec 27 03:07:46 2008 UTC Added files: (Branch: PHP_5_2) /php-src/ext/standard/tests/array bug46873.phpt Modified files: /php-src/ext/standard array.c /php-src NEWS Log: MFH: Fixed bug #46873 (extract($foo) crashes if $foo['foo'] exists) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.61&r2=1.308.2.21.2.62&diff_format=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.308.2.21.2.61 php-src/ext/standard/array.c:1.308.2.21.2.62 --- php-src/ext/standard/array.c:1.308.2.21.2.61 Thu Dec 25 11:05:19 2008 +++ php-src/ext/standard/array.c Sat Dec 27 03:07:45 2008 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.308.2.21.2.61 2008/12/25 11:05:19 felipe Exp $ */ +/* $Id: array.c,v 1.308.2.21.2.62 2008/12/27 03:07:45 lbarnaud Exp $ */ #include "php.h" #include "php_ini.h" @@ -1334,7 +1334,7 @@ Imports variables into symbol table from an array */ PHP_FUNCTION(extract) { - zval **var_array, **z_extract_type, **prefix; + zval **var_array, *orig_var_array, **z_extract_type, **prefix; zval **entry, *data; char *var_name; smart_str final_name = {0}; @@ -1391,7 +1391,15 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "First argument should be an array"); return; } - + + /* var_array is passed by ref for the needs of EXTR_REFS (needs to + * work on the original array to create refs to its members) + * simulate pass_by_value if EXTR_REFS is not used */ + if (!extract_refs) { + orig_var_array = *var_array; + SEPARATE_ARG_IF_REF((*var_array)); + } + zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(var_array), &pos); while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(var_array), (void **)&entry, &pos) == SUCCESS) { key_type = zend_hash_get_current_key_ex(Z_ARRVAL_PP(var_array), &var_name, &var_name_len, &num_key, 0, &pos); @@ -1491,6 +1499,10 @@ zend_hash_move_forward_ex(Z_ARRVAL_PP(var_array), &pos); } + if (!extract_refs) { + zval_ptr_dtor(var_array); + *var_array = orig_var_array; + } smart_str_free(&final_name); RETURN_LONG(count); http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1368&r2=1.2027.2.547.2.1369&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.1368 php-src/NEWS:1.2027.2.547.2.1369 --- php-src/NEWS:1.2027.2.547.2.1368 Wed Dec 24 11:32:45 2008 +++ php-src/NEWS Sat Dec 27 03:07:46 2008 @@ -14,6 +14,7 @@ - Fixed bug #46889 (Memory leak in strtotime()). (Derick) - Fixed bug #46887 (Invalid calls to php_error_docref()). (oeriksson at mandriva dot com, Ilia) +- Fixed bug #46873 (extract($foo) crashes if $foo['foo'] exists). (Arnaud) - Fixed bug #46798 (Crash in mssql extension when retrieving a NULL value inside a binary or image column type). (Ilia) - Fixed bug #46782 (fastcgi.c parse error). (Matt) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/bug46873.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/bug46873.phpt +++ php-src/ext/standard/tests/array/bug46873.phpt --TEST-- Bug #46873 (extract($foo) crashes if $foo['foo'] exists) --FILE-- <?php $foo = array('foo' => 1, 'bar' => 2, 'test' => 3); extract($foo); var_dump($foo, $bar, $test); ?> --EXPECT-- int(1) int(2) int(3)

« previous php.cvs (#55133) next »