lbarnaud Wed Nov 26 00:59:14 2008 UTC
Added files:
/php-src/ext/standard/tests/array extract_variation10.phpt
extract_variation11.phpt
Modified files:
/php-src/ext/standard array.c
Log:
Fixed bugs #44181 & #44182 (extract() and references)
(robin_fernandes at uk dot ibm dot com)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.466&r2=1.467&diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.466 php-src/ext/standard/array.c:1.467
--- php-src/ext/standard/array.c:1.466 Mon Nov 24 19:24:09 2008
+++ php-src/ext/standard/array.c Wed Nov 26 00:59:13 2008
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: array.c,v 1.466 2008/11/24 19:24:09 stas Exp $ */
+/* $Id: array.c,v 1.467 2008/11/26 00:59:13 lbarnaud Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -1461,18 +1461,13 @@
if (extract_refs) {
zval **orig_var;
+ SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
+ zval_add_ref(entry);
+
if (zend_u_hash_find(EG(active_symbol_table),
Z_TYPE(final_name), Z_UNIVAL(final_name), Z_UNILEN(final_name) + 1, (void **)
&orig_var) == SUCCESS) {
- SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
- zval_add_ref(entry);
zval_ptr_dtor(orig_var);
*orig_var = *entry;
} else {
- if (Z_REFCOUNT_P(var_array) > 1 ||
*entry == EG(uninitialized_zval_ptr)) {
-
SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
- } else {
- Z_SET_ISREF_PP(entry);
- }
- zval_add_ref(entry);
zend_u_hash_update(EG(active_symbol_table), Z_TYPE(final_name),
Z_UNIVAL(final_name), Z_UNILEN(final_name) + 1, (void **) entry, sizeof(zval
*), NULL);
}
} else {
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation10.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/extract_variation10.phpt
+++ php-src/ext/standard/tests/array/extract_variation10.phpt
--TEST--
Test extract() function - ensure EXTR_REFS doesn't mess with isRef flag on COW
references to array elements.
--FILE--
<?php
$a = array('foo' => 'original.foo');
$nonref = $a['foo'];
$ref = &$a;
extract($a, EXTR_REFS);
$a['foo'] = 'changed.foo';
var_dump($nonref);
?>
--EXPECTF--
%unicode|string%(12) "original.foo"
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation11.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/extract_variation11.phpt
+++ php-src/ext/standard/tests/array/extract_variation11.phpt
--TEST--
Test extract() function - ensure EXTR_REFS works when array is referenced and
keys clash with variables in current scope.
--FILE--
<?php
$a = array('foo' => 'original.foo');
$ref = &$a;
$foo = 'test';
extract($a, EXTR_OVERWRITE|EXTR_REFS);
$foo = 'changed.foo';
var_dump($a['foo']);
?>
--EXPECTF--
%unicode|string%(11) "changed.foo"
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php