lbarnaud                Sat Dec 27 03:06:16 2008 UTC

  Added files:                 
    /php-src/ext/standard/tests/array   bug46873.phpt 

  Modified files:              
    /php-src/ext/standard       array.c 
  Log:
  Fixed bug #46873 (extract($foo) crashes if $foo['foo'] exists)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.468&r2=1.469&diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.468 php-src/ext/standard/array.c:1.469
--- php-src/ext/standard/array.c:1.468  Fri Dec 12 19:19:04 2008
+++ php-src/ext/standard/array.c        Sat Dec 27 03:06:16 2008
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: array.c,v 1.468 2008/12/12 19:19:04 andrei Exp $ */
+/* $Id: array.c,v 1.469 2008/12/27 03:06:16 lbarnaud Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -1372,6 +1372,13 @@
                zend_rebuild_symbol_table(TSRMLS_C);
        }
 
+       /* 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) {
+               SEPARATE_ARG_IF_REF(var_array);
+       }
+
        zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(var_array), &pos);
        while (zend_hash_get_current_data_ex(Z_ARRVAL_P(var_array), (void 
**)&entry, &pos) == SUCCESS) {
                zval final_name;
@@ -1484,6 +1491,10 @@
                zend_hash_move_forward_ex(Z_ARRVAL_P(var_array), &pos);
        }
 
+       if (!extract_refs) {
+               zval_ptr_dtor(&var_array);
+       }
+
        RETURN_LONG(count);
 }
 /* }}} */

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)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to