lbarnaud                Wed Nov 26 00:59:41 2008 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/standard/tests/array   extract_variation10.phpt 
                                        extract_variation11.phpt 

  Modified files:              
    /php-src/ext/standard       array.c 
  Log:
  MFH: 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.308.2.21.2.37.2.46&r2=1.308.2.21.2.37.2.47&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.46 
php-src/ext/standard/array.c:1.308.2.21.2.37.2.47
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.46   Mon Nov 24 18:12:16 2008
+++ php-src/ext/standard/array.c        Wed Nov 26 00:59:41 2008
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.37.2.46 2008/11/24 18:12:16 stas Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.47 2008/11/26 00:59:41 lbarnaud Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -1359,18 +1359,13 @@
                        if (extract_refs) {
                                zval **orig_var;
 
+                               SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
+                               zval_add_ref(entry);
+
                                if (zend_hash_find(EG(active_symbol_table), 
Z_STRVAL(final_name), Z_STRLEN(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_hash_update(EG(active_symbol_table), Z_STRVAL(final_name), 
Z_STRLEN(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

Reply via email to