moriyoshi               Thu Oct  2 18:22:16 2003 EDT

  Modified files:              (Branch: PHP_4_3)
    /php-src/ext/standard       array.c 
    /php-src    NEWS 
  Log:
  MFH(r-1.252): Fixed bug #25708 (extract($GLOBALS, EXTR_REFS) mangles $GLOBALS)
  
  
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.199.2.27 php-src/ext/standard/array.c:1.199.2.28
--- php-src/ext/standard/array.c:1.199.2.27     Thu Sep 11 13:28:27 2003
+++ php-src/ext/standard/array.c        Thu Oct  2 18:22:14 2003
@@ -22,7 +22,7 @@
 */
 
 
-/* $Id: array.c,v 1.199.2.27 2003/09/11 17:28:27 jay Exp $ */
+/* $Id: array.c,v 1.199.2.28 2003/10/02 22:22:14 moriyoshi Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -1152,7 +1152,7 @@
        ulong num_key;
        uint var_name_len;
        int var_exists, extract_type, key_type, count = 0;
-       zend_bool extract_refs = 0;
+       int extract_refs = 0;
        HashPosition pos;
 
        switch (ZEND_NUM_ARGS()) {
@@ -1169,7 +1169,7 @@
                        }
                        convert_to_long_ex(z_extract_type);
                        extract_type = Z_LVAL_PP(z_extract_type);
-                       extract_refs = (extract_type & EXTR_REFS)>>8;
+                       extract_refs = (extract_type & EXTR_REFS);
                        extract_type &= 0xff;
                        if (extract_type > EXTR_SKIP && extract_type <= 
EXTR_PREFIX_IF_EXISTS) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Prefix 
expected to be specified");
@@ -1183,7 +1183,7 @@
                        }
                        convert_to_long_ex(z_extract_type);
                        extract_type = Z_LVAL_PP(z_extract_type);
-                       extract_refs = (extract_type & EXTR_REFS)>>8;
+                       extract_refs = (extract_type & EXTR_REFS);
                        extract_type &= 0xff;
                        convert_to_string_ex(prefix);
                        break;
@@ -1273,17 +1273,14 @@
                                if (extract_refs) {
                                        zval **orig_var;
 
-                                       (*entry)->is_ref = 1;
-                                       (*entry)->refcount++;
-                                       if (zend_hash_find(EG(active_symbol_table), 
final_name.c, final_name.len+1, (void **) &orig_var) == SUCCESS
-                                               && PZVAL_IS_REF(*orig_var)) {
-
-                                               (*entry)->refcount += 
(*orig_var)->refcount-2;
-                                               zval_dtor(*orig_var);
-                                               FREE_ZVAL(*orig_var);
+                                       SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
+                                       zval_add_ref(entry);
+
+                                       if (zend_hash_find(EG(active_symbol_table), 
final_name.c, final_name.len+1, (void **) &orig_var) == SUCCESS) {
+                                               zval_ptr_dtor(orig_var);
                                                *orig_var = *entry;
                                        } else {
-                                               
zend_hash_update(EG(active_symbol_table), final_name.c, final_name.len+1, entry, 
sizeof(zval *), NULL);
+                                               
zend_hash_update(EG(active_symbol_table), final_name.c, final_name.len+1, (void **) 
entry, sizeof(zval *), NULL);
                                        }
                                } else {
                                        MAKE_STD_ZVAL(data);
Index: php-src/NEWS
diff -u php-src/NEWS:1.1247.2.419 php-src/NEWS:1.1247.2.420
--- php-src/NEWS:1.1247.2.419   Thu Oct  2 10:03:17 2003
+++ php-src/NEWS        Thu Oct  2 18:22:15 2003
@@ -3,6 +3,7 @@
 ?? Oct 2003, Version 4.3.4RC2
 - Fixed multibyte regex engine to properly handle ".*" pattern under
   POSIX compatible mode. (K.Kosako <kosako at sofnec.co.jp>, Moriyoshi)
+- Fixed bug #25708 (extract($GLOBALS, EXTR_REFS) mangles $GLOBALS). (Moriyoshi)
 - Fixed bug #25707 (html_entity_decode() over-decodes &amp;lt;). (Moriyoshi)
 - Fixed bug #25703 (openssl configure check failed). (Jani)
 - Fixed bug #25701 (On flush() set headers_sent in apache2handler). (Ilia)

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

Reply via email to